From 1a3bd2bec71f2cbbd78b3e33f7ce11ed72c22547 Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Mon, 11 Sep 2017 11:56:20 +0200 Subject: [PATCH] [ALL] Add SearchTableApi in ADQLLib, and make functions returning ArrayList and HashMap more generic by returning resp. a List and Map instead. --- src/adql/db/DBChecker.java | 24 +++++----- src/adql/db/SearchColumnList.java | 25 +++++----- src/adql/db/SearchTableApi.java | 47 +++++++++++++++++++ src/adql/db/SearchTableList.java | 20 ++++---- src/adql/query/ClauseSelect.java | 12 +++-- src/adql/query/from/ADQLJoin.java | 15 +++--- src/adql/query/from/ADQLTable.java | 9 ++-- src/adql/query/from/FromContent.java | 10 ++-- src/adql/translator/JDBCTranslator.java | 8 ++-- src/cds/utils/TextualSearchList.java | 11 +++-- src/tap/metadata/TAPMetadata.java | 5 +- src/uws/AcceptHeader.java | 10 ++-- src/uws/UWSToolBox.java | 10 ++-- src/uws/job/JobList.java | 7 +-- src/uws/job/parameters/UWSParameters.java | 6 +-- src/uws/service/AbstractUWSFactory.java | 4 +- src/uws/service/UWSService.java | 7 +-- src/uws/service/UWSServlet.java | 6 +-- .../backup/DefaultUWSBackupManager.java | 7 +-- .../service/error/DefaultUWSErrorWriter.java | 8 ++-- src/uws/service/file/LocalUWSFileManager.java | 9 ++-- test/adql/query/TestADQLObjectPosition.java | 7 +-- 22 files changed, 163 insertions(+), 104 deletions(-) create mode 100644 src/adql/db/SearchTableApi.java diff --git a/src/adql/db/DBChecker.java b/src/adql/db/DBChecker.java index 876cf2a..8f32aed 100644 --- a/src/adql/db/DBChecker.java +++ b/src/adql/db/DBChecker.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Stack; @@ -98,12 +99,12 @@ import adql.search.SimpleSearchHandler; * </i></p> * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (04/2017) + * @version 1.4 (09/2017) */ public class DBChecker implements QueryChecker { /** List of all available tables ({@link DBTable}). */ - protected SearchTableList lstTables; + protected SearchTableApi lstTables; /** <p>List of all allowed geometrical functions (i.e. CONTAINS, REGION, POINT, COORD2, ...).</p> * <p> @@ -337,8 +338,9 @@ public class DBChecker implements QueryChecker { * <p>Sets the list of all available tables.</p> * * <p><i><u>Note:</u> - * Only if the given collection is NOT an instance of {@link SearchTableList}, - * the collection will be copied inside a new {@link SearchTableList}, otherwise it is used as provided. + * Only if the given collection is NOT an implementation of + * {@link SearchTableApi}, the collection will be copied inside a new + * {@link SearchTableList}, otherwise it is used as provided. * </i></p> * * @param tables List of {@link DBTable}s. @@ -346,8 +348,8 @@ public class DBChecker implements QueryChecker { public final void setTables(final Collection<? extends DBTable> tables){ if (tables == null) lstTables = new SearchTableList(); - else if (tables instanceof SearchTableList) - lstTables = (SearchTableList)tables; + else if (tables instanceof SearchTableApi) + lstTables = (SearchTableApi)tables; else lstTables = new SearchTableList(tables); } @@ -546,7 +548,7 @@ public class DBChecker implements QueryChecker { // first, try to resolve the table by table alias: if (table.getTableName() != null && table.getSchemaName() == null){ - ArrayList<ADQLTable> tables = query.getFrom().getTablesByAlias(table.getTableName(), table.isCaseSensitive(IdentifierField.TABLE)); + List<ADQLTable> tables = query.getFrom().getTablesByAlias(table.getTableName(), table.isCaseSensitive(IdentifierField.TABLE)); if (tables.size() == 1) dbTable = tables.get(0).getDBLink(); } @@ -575,7 +577,7 @@ public class DBChecker implements QueryChecker { * @throws ParseException An {@link UnresolvedTableException} if the given table can't be resolved. */ protected DBTable resolveTable(final ADQLTable table) throws ParseException{ - ArrayList<DBTable> tables = lstTables.search(table); + List<DBTable> tables = lstTables.search(table); // good if only one table has been found: if (tables.size() == 1) @@ -691,7 +693,7 @@ public class DBChecker implements QueryChecker { * or an {@link UnresolvedTableException} if its table reference can't be resolved. */ protected DBColumn resolveColumn(final ADQLColumn column, final SearchColumnList dbColumns, Stack<SearchColumnList> fathersList) throws ParseException{ - ArrayList<DBColumn> foundColumns = dbColumns.search(column); + List<DBColumn> foundColumns = dbColumns.search(column); // good if only one column has been found: if (foundColumns.size() == 1) @@ -737,7 +739,7 @@ public class DBChecker implements QueryChecker { * So, try resolving the name as an alias. * If it fails, perform the normal column resolution.*/ if (col.getTableName() == null){ - ArrayList<SelectItem> founds = select.searchByAlias(col.getColumnName(), col.isCaseSensitive(IdentifierField.COLUMN)); + List<SelectItem> founds = select.searchByAlias(col.getColumnName(), col.isCaseSensitive(IdentifierField.COLUMN)); if (founds.size() == 1) return null; else if (founds.size() > 1) @@ -779,7 +781,7 @@ public class DBChecker implements QueryChecker { col.setPosition(colRef.getPosition()); // search among the select_item aliases: - ArrayList<SelectItem> founds = select.searchByAlias(colRef.getColumnName(), colRef.isCaseSensitive()); + List<SelectItem> founds = select.searchByAlias(colRef.getColumnName(), colRef.isCaseSensitive()); if (founds.size() == 1) return null; else if (founds.size() > 1) diff --git a/src/adql/db/SearchColumnList.java b/src/adql/db/SearchColumnList.java index b403fa5..22c8360 100644 --- a/src/adql/db/SearchColumnList.java +++ b/src/adql/db/SearchColumnList.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 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) */ @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -46,7 +47,7 @@ import cds.utils.TextualSearchList; * </i></p> * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (08/2015) + * @version 1.4 (09/2017) */ public class SearchColumnList extends TextualSearchList<DBColumn> { private static final long serialVersionUID = 1L; @@ -55,10 +56,10 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { private boolean distinct = false; /** Case-sensitive dictionary of table aliases. (tableAlias <-> TableName) */ - private final HashMap<String,String> tableAliases = new HashMap<String,String>(); + private final Map<String,String> tableAliases = new HashMap<String,String>(); /** Case-insensitive dictionary of table aliases. (tablealias <-> List<TableName>) */ - private final HashMap<String,ArrayList<String>> mapAliases = new HashMap<String,ArrayList<String>>(); + private final Map<String,List<String>> mapAliases = new HashMap<String,List<String>>(); /* ************ */ /* CONSTRUCTORS */ @@ -122,7 +123,7 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { if (tableAlias != null && tableName != null){ tableAliases.put(tableAlias, tableName); - ArrayList<String> aliases = mapAliases.get(tableAlias.toLowerCase()); + List<String> aliases = mapAliases.get(tableAlias.toLowerCase()); if (aliases == null){ aliases = new ArrayList<String>(); mapAliases.put(tableAlias.toLowerCase(), aliases); @@ -139,7 +140,7 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { public final void removeTableAlias(final String tableAlias){ tableAliases.remove(tableAlias); - ArrayList<String> aliases = mapAliases.get(tableAlias.toLowerCase()); + List<String> aliases = mapAliases.get(tableAlias.toLowerCase()); if (aliases != null){ aliases.remove(tableAlias); if (aliases.isEmpty()) @@ -171,7 +172,7 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { * * @see TextualSearchList#get(String) */ - public ArrayList<DBColumn> search(final String columnName){ + public List<DBColumn> search(final String columnName){ return get(columnName); } @@ -187,7 +188,7 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { * * @see #search(String, String, String, String, byte) */ - public final ArrayList<DBColumn> search(final String catalog, final String schema, final String table, final String column){ + public final List<DBColumn> search(final String catalog, final String schema, final String table, final String column){ return search(catalog, schema, table, column, (byte)0); } @@ -200,7 +201,7 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { * * @see #search(String, String, String, String, byte) */ - public ArrayList<DBColumn> search(final ADQLColumn column){ + public List<DBColumn> search(final ADQLColumn column){ return search(column.getCatalogName(), column.getSchemaName(), column.getTableName(), column.getColumnName(), column.getCaseSensitive()); } @@ -217,15 +218,15 @@ public class SearchColumnList extends TextualSearchList<DBColumn> { * * @see IdentifierField */ - public ArrayList<DBColumn> search(final String catalog, final String schema, final String table, final String column, final byte caseSensitivity){ + public List<DBColumn> search(final String catalog, final String schema, final String table, final String column, final byte caseSensitivity){ - ArrayList<DBColumn> tmpResult = get(column, IdentifierField.COLUMN.isCaseSensitive(caseSensitivity)); + List<DBColumn> tmpResult = get(column, IdentifierField.COLUMN.isCaseSensitive(caseSensitivity)); /* WITH TABLE PREFIX */ if (table != null){ /* 1. Figure out the table alias */ String tableName = null; - ArrayList<String> aliasMatches = null; + List<String> aliasMatches = null; // Case sensitive => tableName is set , aliasMatches = null if (IdentifierField.TABLE.isCaseSensitive(caseSensitivity)){ diff --git a/src/adql/db/SearchTableApi.java b/src/adql/db/SearchTableApi.java new file mode 100644 index 0000000..c7d047a --- /dev/null +++ b/src/adql/db/SearchTableApi.java @@ -0,0 +1,47 @@ +package adql.db; + +/* + * This file is part of ADQLLibrary. + * + * ADQLLibrary 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. + * + * ADQLLibrary 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 ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright 2017 - Astronomisches Rechen Institut (ARI) + */ + +import java.util.List; + +import adql.query.from.ADQLTable; + +/** + * Simple interface about a class which allows to search for a specified + * {@link ADQLTable}. + * + * @author Grégory Mantelet (ARI) + * @version 1.4 (09/2017) + * @since 1.4 + * + * @see SearchTableList + */ +public interface SearchTableApi { + + /** + * Searches all {@link DBTable} elements corresponding to the given {@link ADQLTable} (case insensitive). + * + * @param table An {@link ADQLTable}. + * + * @return The list of all corresponding {@link DBTable} elements. + */ + public List<DBTable> search(final ADQLTable table); + +} \ No newline at end of file diff --git a/src/adql/db/SearchTableList.java b/src/adql/db/SearchTableList.java index 1468218..8522d24 100644 --- a/src/adql/db/SearchTableList.java +++ b/src/adql/db/SearchTableList.java @@ -16,12 +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 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) */ import java.util.ArrayList; import java.util.Collection; +import java.util.List; import adql.query.IdentifierField; import adql.query.from.ADQLTable; @@ -36,9 +37,9 @@ import cds.utils.TextualSearchList; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (08/2015) + * @version 1.4 (09/2017) */ -public class SearchTableList extends TextualSearchList<DBTable> { +public class SearchTableList extends TextualSearchList<DBTable> implements SearchTableApi { private static final long serialVersionUID = 1L; /** Indicates whether multiple occurrences are allowed. */ @@ -105,7 +106,7 @@ public class SearchTableList extends TextualSearchList<DBTable> { * * @see TextualSearchList#get(String) */ - public ArrayList<DBTable> search(final String tableName){ + public List<DBTable> search(final String tableName){ return get(tableName); } @@ -120,7 +121,7 @@ public class SearchTableList extends TextualSearchList<DBTable> { * * @see #search(String, String, String, byte) */ - public final ArrayList<DBTable> search(final String catalog, final String schema, final String table){ + public final List<DBTable> search(final String catalog, final String schema, final String table){ return search(catalog, schema, table, (byte)0); } @@ -133,7 +134,8 @@ public class SearchTableList extends TextualSearchList<DBTable> { * * @see #search(String, String, String, byte) */ - public ArrayList<DBTable> search(final ADQLTable table){ + @Override + public List<DBTable> search(final ADQLTable table){ return search(table.getCatalogName(), table.getSchemaName(), table.getTableName(), table.getCaseSensitive()); } @@ -149,11 +151,11 @@ public class SearchTableList extends TextualSearchList<DBTable> { * * @see IdentifierField */ - public ArrayList<DBTable> search(final String catalog, final String schema, final String table, final byte caseSensitivity){ - ArrayList<DBTable> tmpResult = get(table, IdentifierField.TABLE.isCaseSensitive(caseSensitivity)); + public List<DBTable> search(final String catalog, final String schema, final String table, final byte caseSensitivity){ + List<DBTable> tmpResult = get(table, IdentifierField.TABLE.isCaseSensitive(caseSensitivity)); if (schema != null){ - ArrayList<DBTable> result = new ArrayList<DBTable>(); + List<DBTable> result = new ArrayList<DBTable>(); for(DBTable match : tmpResult){ // No schema name (<=> no schema), then this table can not be a good match: diff --git a/src/adql/query/ClauseSelect.java b/src/adql/query/ClauseSelect.java index 0f63247..2625623 100644 --- a/src/adql/query/ClauseSelect.java +++ b/src/adql/query/ClauseSelect.java @@ -16,10 +16,12 @@ package adql.query; * 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 - 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) */ import java.util.ArrayList; +import java.util.List; import adql.query.operand.ADQLOperand; @@ -30,8 +32,8 @@ import adql.query.operand.ADQLOperand; * <ul><li>The user can specify the maximum number of rows the query must return.</li> * <li>He can also ask that all the returned rows are unique according to the first returned column.</li></ul></p> * - * @author Grégory Mantelet (CDS) - * @version 06/2011 + * @author Grégory Mantelet (CDS;ARI) + * @version 1.4 (09/2017) */ public class ClauseSelect extends ClauseADQL<SelectItem> { @@ -218,7 +220,7 @@ public class ClauseSelect extends ClauseADQL<SelectItem> { * @see #searchByAlias(String, boolean) */ public ADQLOperand searchByAlias(String alias){ - ArrayList<SelectItem> founds = searchByAlias(alias, true); + List<SelectItem> founds = searchByAlias(alias, true); if (founds.isEmpty()) return null; else @@ -231,7 +233,7 @@ public class ClauseSelect extends ClauseADQL<SelectItem> { * @param alias Alias of the operand to retrieve. * @return All the corresponding select items. */ - public ArrayList<SelectItem> searchByAlias(String alias, boolean caseSensitive){ + public List<SelectItem> searchByAlias(String alias, boolean caseSensitive){ if (alias == null) return new ArrayList<SelectItem>(0); diff --git a/src/adql/query/from/ADQLJoin.java b/src/adql/query/from/ADQLJoin.java index 119154c..a3acdee 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-2016 - 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) */ @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -42,7 +43,7 @@ import adql.query.operand.ADQLColumn; * Defines a join between two "tables". * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (03/2016) + * @version 1.4 (09/2017) */ public abstract class ADQLJoin implements ADQLObject, FromContent { @@ -445,7 +446,7 @@ public abstract class ADQLJoin implements ADQLObject, FromContent { } 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); + List<DBColumn> result = list.search(null, null, null, columnName, caseSensitive); if (result.isEmpty()) return null; else if (result.size() > 1) @@ -465,15 +466,15 @@ public abstract class ADQLJoin implements ADQLObject, FromContent { } @Override - public ArrayList<ADQLTable> getTables(){ - ArrayList<ADQLTable> tables = leftTable.getTables(); + public List<ADQLTable> getTables(){ + List<ADQLTable> tables = leftTable.getTables(); tables.addAll(rightTable.getTables()); return tables; } @Override - public ArrayList<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive){ - ArrayList<ADQLTable> tables = leftTable.getTablesByAlias(alias, caseSensitive); + public List<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive){ + List<ADQLTable> tables = leftTable.getTablesByAlias(alias, caseSensitive); tables.addAll(rightTable.getTablesByAlias(alias, caseSensitive)); return tables; } diff --git a/src/adql/query/from/ADQLTable.java b/src/adql/query/from/ADQLTable.java index baa2599..c01847b 100644 --- a/src/adql/query/from/ADQLTable.java +++ b/src/adql/query/from/ADQLTable.java @@ -16,11 +16,12 @@ 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-2016 - 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) */ import java.util.ArrayList; +import java.util.List; import java.util.NoSuchElementException; import adql.db.DBChecker; @@ -39,7 +40,7 @@ import adql.query.TextPosition; * A table reference may have an alias (MUST if it is a sub-query). * * @author Grégory Mantelet (CDS;ARI) - * @version 2.1 (07/2016) + * @version 1.4 (09/2017) */ public class ADQLTable implements ADQLObject, FromContent { @@ -488,14 +489,14 @@ public class ADQLTable implements ADQLObject, FromContent { } @Override - public ArrayList<ADQLTable> getTables(){ + public List<ADQLTable> getTables(){ ArrayList<ADQLTable> tables = new ArrayList<ADQLTable>(); tables.add(this); return tables; } @Override - public ArrayList<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive){ + public List<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive){ ArrayList<ADQLTable> tables = new ArrayList<ADQLTable>(); if (hasAlias()){ diff --git a/src/adql/query/from/FromContent.java b/src/adql/query/from/FromContent.java index a3df9cc..60cfe90 100644 --- a/src/adql/query/from/FromContent.java +++ b/src/adql/query/from/FromContent.java @@ -16,11 +16,11 @@ 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-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) */ -import java.util.ArrayList; +import java.util.List; import adql.db.DBColumn; import adql.db.SearchColumnList; @@ -33,7 +33,7 @@ import adql.query.TextPosition; * It could be either a table ({@link ADQLTable}) or a join ({@link ADQLJoin}). * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (06/2015) + * @version 1.4 (09/2017) */ public interface FromContent extends ADQLObject { @@ -52,7 +52,7 @@ public interface FromContent extends ADQLObject { * * @return The list of all {@link ADQLTable}s found. */ - public ArrayList<ADQLTable> getTables(); + public List<ADQLTable> getTables(); /** * <p>Gets all the table whose the alias is equals to the given one.</p> @@ -66,7 +66,7 @@ public interface FromContent extends ADQLObject { * * @return The list of all tables found. */ - public ArrayList<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive); + public List<ADQLTable> getTablesByAlias(final String alias, final boolean caseSensitive); /** * Set the position of this {@link FromContent} in the given ADQL query string. diff --git a/src/adql/translator/JDBCTranslator.java b/src/adql/translator/JDBCTranslator.java index e144121..64a301f 100644 --- a/src/adql/translator/JDBCTranslator.java +++ b/src/adql/translator/JDBCTranslator.java @@ -16,12 +16,12 @@ package adql.translator; * 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 2015-2016 - Astronomisches Rechen Institut (ARI) + * Copyright 2017 - Astronomisches Rechen Institut (ARI) */ -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import adql.db.DBColumn; import adql.db.DBTable; @@ -166,7 +166,7 @@ import adql.query.operand.function.geometry.RegionFunction; * </p> * * @author Grégory Mantelet (ARI) - * @version 1.4 (07/2016) + * @version 1.4 (09/2017) * @since 1.4 * * @see PostgreSQLTranslator @@ -472,7 +472,7 @@ public abstract class JDBCTranslator implements ADQLTranslator { }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(); + List<ADQLTable> tables = item.getQuery().getFrom().getTables(); for(ADQLTable table : tables){ if (table.hasAlias()){ String key = getQualifiedTableName(table.getDBLink()); diff --git a/src/cds/utils/TextualSearchList.java b/src/cds/utils/TextualSearchList.java index 3dd9888..2cd9c8d 100644 --- a/src/cds/utils/TextualSearchList.java +++ b/src/cds/utils/TextualSearchList.java @@ -16,13 +16,14 @@ package cds.utils; * 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) */ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; /** * <p>A TextualSearchList is an {@link ArrayList} with a textual search capability.</p> @@ -39,7 +40,7 @@ import java.util.HashMap; * * @param <E> Type of object to manage in this list. * @author Grégory Mantelet (CDS;ARI) - * @version 1.1 (11/2013) + * @version 1.4 (09/2017) */ public class TextualSearchList< E > extends ArrayList<E> { private static final long serialVersionUID = 1L; @@ -173,7 +174,7 @@ public class TextualSearchList< E > extends ArrayList<E> { * * @return The corresponding object or <code>null</code>. */ - public final ArrayList<E> get(final String key){ + public final List<E> get(final String key){ return get(key, false); } @@ -186,7 +187,7 @@ public class TextualSearchList< E > extends ArrayList<E> { * @return All the objects whose the key is the same as the given one. */ @SuppressWarnings("unchecked") - public ArrayList<E> get(final String key, final boolean caseSensitive){ + public List<E> get(final String key, final boolean caseSensitive){ if (key == null) return new ArrayList<E>(0); @@ -419,7 +420,7 @@ public class TextualSearchList< E > extends ArrayList<E> { * @param <E> The type of objects managed in the given map. */ private static final < E > void removeFromMap(final HashMap<String,ArrayList<E>> map, final String key, final E value){ - ArrayList<E> lst = map.get(key); + List<E> lst = map.get(key); if (lst != null){ lst.remove(value); if (lst.isEmpty()) diff --git a/src/tap/metadata/TAPMetadata.java b/src/tap/metadata/TAPMetadata.java index 7181bc5..d567267 100644 --- a/src/tap/metadata/TAPMetadata.java +++ b/src/tap/metadata/TAPMetadata.java @@ -25,6 +25,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -64,7 +65,7 @@ import uws.UWSToolBox; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 2.1 (03/2017) + * @version 2.1 (09/2017) */ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResource { @@ -378,7 +379,7 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour * @return A list of all the tables which have the given ADQL name, * or an empty list if no such table can be found. */ - public ArrayList<DBTable> getTable(String tableName){ + public List<DBTable> getTable(String tableName){ ArrayList<DBTable> tables = new ArrayList<DBTable>(); for(TAPSchema s : this) if (s.hasTable(tableName)) diff --git a/src/uws/AcceptHeader.java b/src/uws/AcceptHeader.java index f12ed18..47f56ef 100644 --- a/src/uws/AcceptHeader.java +++ b/src/uws/AcceptHeader.java @@ -16,7 +16,8 @@ package uws; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012 - 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) */ import java.util.ArrayList; @@ -25,16 +26,15 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; - import java.util.Map.Entry; +import java.util.Set; /** * Parser of HTTP Accept header. * It takes into account the order of the different MIME types and their respective quality. * * @author Brice Gassmann (CDS) & modified by Grégory Mantelet (CDS) - * @version 12/2010 + * @version 4.2 (09/2017) */ public class AcceptHeader { @@ -136,7 +136,7 @@ public class AcceptHeader { * * @return The ordered list of the extracted MIME types. */ - public ArrayList<String> getOrderedMimeTypes(){ + public List<String> getOrderedMimeTypes(){ Float[] qualities = mSortedMimeTypes.keySet().toArray(new Float[0]); Arrays.sort(qualities, Collections.reverseOrder()); diff --git a/src/uws/UWSToolBox.java b/src/uws/UWSToolBox.java index e622c56..bb3df0d 100644 --- a/src/uws/UWSToolBox.java +++ b/src/uws/UWSToolBox.java @@ -16,7 +16,7 @@ package uws; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. 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) */ @@ -55,7 +55,7 @@ import uws.service.request.UploadFile; * Some useful functions for the managing of a UWS service. * * @author Grégory Mantelet (CDS;ARI) - * @version 4.2 (07/2015) + * @version 4.2 (09/2017) */ public class UWSToolBox { @@ -137,7 +137,7 @@ public class UWSToolBox { * @return The corresponding map of string. */ @SuppressWarnings("unchecked") - public static final HashMap<String,String> getParamsMap(final HttpServletRequest req){ + public static final Map<String,String> getParamsMap(final HttpServletRequest req){ HashMap<String,String> map = new HashMap<String,String>(); /* If the attribute "PARAMETERS" has been already set by the UWS library, @@ -325,7 +325,7 @@ public class UWSToolBox { } /** - * Check whether the parameter specified with the given pair (name,value) exists in the given HTTP request. + * Check whether the parameter specified with the given pair (name,value) exists in the given HTTP request. * * @param name Name of the parameter to search. * @param value Expected value of the parameter. @@ -351,7 +351,7 @@ public class UWSToolBox { } /** - * Get the parameter specified by the given name from the given HTTP request. + * Get the parameter specified by the given name from the given HTTP request. * * @param name Name of the parameter to search. * @param request HTTP request in which the given pair must be searched. diff --git a/src/uws/job/JobList.java b/src/uws/job/JobList.java index 90e43f4..384039c 100644 --- a/src/uws/job/JobList.java +++ b/src/uws/job/JobList.java @@ -16,13 +16,14 @@ package uws.job; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. 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) */ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import uws.UWSException; @@ -96,7 +97,7 @@ import uws.service.log.UWSLog.LogLevel; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (11/2014) + * @version 4.2 (09/2017) * * @see UWSJob */ @@ -493,7 +494,7 @@ public class JobList extends SerializableUWSObject implements Iterable<UWSJob> { * * @return All the corresponding jobs. */ - public final ArrayList<UWSJob> searchJobs(String runID){ + public final List<UWSJob> searchJobs(String runID){ ArrayList<UWSJob> foundJobs = new ArrayList<UWSJob>(); runID = (runID != null) ? runID.trim() : runID; diff --git a/src/uws/job/parameters/UWSParameters.java b/src/uws/job/parameters/UWSParameters.java index 734a79f..8a7da5e 100644 --- a/src/uws/job/parameters/UWSParameters.java +++ b/src/uws/job/parameters/UWSParameters.java @@ -16,7 +16,7 @@ package uws.job.parameters; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. 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) */ @@ -116,7 +116,7 @@ import uws.service.request.UploadFile; * <p><i><u>note 2:</u> If several values have been submitted for the same UWS standard parameter, just the last occurrence is taken into account.</i></p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (12/2014) + * @version 4.2 (09/2017) */ public class UWSParameters implements Iterable<Entry<String,Object>> { @@ -331,7 +331,7 @@ public class UWSParameters implements Iterable<Entry<String,Object>> { * * @return Default list of controllers. <i><u>note:</u> This map can be modified !</i> */ - protected HashMap<String,InputParamController> getDefaultControllers(){ + protected Map<String,InputParamController> getDefaultControllers(){ HashMap<String,InputParamController> controllers = new HashMap<String,InputParamController>(2); controllers.put(UWSJob.PARAM_EXECUTION_DURATION, new ExecutionDurationController()); controllers.put(UWSJob.PARAM_DESTRUCTION_TIME, new DestructionTimeController()); diff --git a/src/uws/service/AbstractUWSFactory.java b/src/uws/service/AbstractUWSFactory.java index d066712..6acbe57 100644 --- a/src/uws/service/AbstractUWSFactory.java +++ b/src/uws/service/AbstractUWSFactory.java @@ -49,7 +49,7 @@ import uws.service.request.UWSRequestParser; * Only the function which creates a {@link JobThread} from a {@link UWSJob} needs to be implemented.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.2 (06/2017) + * @version 4.2 (09/2017) */ public abstract class AbstractUWSFactory implements UWSFactory { @@ -147,7 +147,7 @@ public abstract class AbstractUWSFactory implements UWSFactory { * * @return Names of the expected additional parameters. */ - public final ArrayList<String> getExpectedAdditionalParameters(){ + public final List<String> getExpectedAdditionalParameters(){ return expectedAdditionalParams; } diff --git a/src/uws/service/UWSService.java b/src/uws/service/UWSService.java index 248f25b..c35cad9 100644 --- a/src/uws/service/UWSService.java +++ b/src/uws/service/UWSService.java @@ -16,7 +16,7 @@ package uws.service; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2016 - 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) */ @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Vector; @@ -137,7 +138,7 @@ import uws.service.request.RequestParser; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.2 (06/2016) + * @version 4.2 (09/2017) */ public class UWSService implements UWS { @@ -721,7 +722,7 @@ public class UWSService implements UWS { if (mimeTypes != null){ // Parse the given MIME types list: AcceptHeader accept = new AcceptHeader(mimeTypes); - ArrayList<String> lstMimeTypes = accept.getOrderedMimeTypes(); + List<String> lstMimeTypes = accept.getOrderedMimeTypes(); // Try each of them and stop at the first which match with an existing serializer: for(int i = 0; choosenSerializer == null && i < lstMimeTypes.size(); i++) diff --git a/src/uws/service/UWSServlet.java b/src/uws/service/UWSServlet.java index d766054..46f7ea6 100644 --- a/src/uws/service/UWSServlet.java +++ b/src/uws/service/UWSServlet.java @@ -150,7 +150,7 @@ import uws.service.request.UploadFile; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.2 (06/2017) + * @version 4.2 (09/2017) */ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory { private static final long serialVersionUID = 1L; @@ -937,7 +937,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory * * @return Names of the expected additional parameters. */ - public final ArrayList<String> getExpectedAdditionalParameters(){ + public final List<String> getExpectedAdditionalParameters(){ return expectedAdditionalParams; } @@ -1214,7 +1214,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory if (mimeTypes != null){ // Parse the given MIME types list: AcceptHeader accept = new AcceptHeader(mimeTypes); - ArrayList<String> lstMimeTypes = accept.getOrderedMimeTypes(); + List<String> lstMimeTypes = accept.getOrderedMimeTypes(); // Try each of them and stop at the first which match with an existing serializer: for(int i = 0; choosenSerializer == null && i < lstMimeTypes.size(); i++) diff --git a/src/uws/service/backup/DefaultUWSBackupManager.java b/src/uws/service/backup/DefaultUWSBackupManager.java index d749be5..021b478 100644 --- a/src/uws/service/backup/DefaultUWSBackupManager.java +++ b/src/uws/service/backup/DefaultUWSBackupManager.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Timer; @@ -86,7 +87,7 @@ import uws.service.request.UploadFile; * <p>Another positive value will be considered as the frequency (in milliseconds) of the automatic backup (= {@link #saveAll()}).</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.2 (06/2017) + * @version 4.2 (09/2017) */ public class DefaultUWSBackupManager implements UWSBackupManager { @@ -914,7 +915,7 @@ public class DefaultUWSBackupManager implements UWSBackupManager { endTime = -1; HashMap<String,Object> inputParams = new HashMap<String,Object>(10); //Map<String, Object> params = null; - ArrayList<Result> results = null; + List<Result> results = null; ErrorSummary error = null; JSONArray uploads = null; JobInfo jobInfo = null; @@ -1156,7 +1157,7 @@ public class DefaultUWSBackupManager implements UWSBackupManager { * * @see #getResult(JSONObject) */ - protected ArrayList<Result> getResults(final JSONArray array) throws UWSException{ + protected List<Result> getResults(final JSONArray array) throws UWSException{ if (array == null || array.length() == 0) return null; diff --git a/src/uws/service/error/DefaultUWSErrorWriter.java b/src/uws/service/error/DefaultUWSErrorWriter.java index 71ec87e..8d7e782 100644 --- a/src/uws/service/error/DefaultUWSErrorWriter.java +++ b/src/uws/service/error/DefaultUWSErrorWriter.java @@ -16,7 +16,7 @@ package uws.service.error; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. 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) */ @@ -25,7 +25,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.util.ArrayList; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -69,7 +69,7 @@ import uws.service.log.UWSLog.LogLevel; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (04/2015) + * @version 4.2 (09/2017) */ public class DefaultUWSErrorWriter implements ServiceErrorWriter { @@ -149,7 +149,7 @@ public class DefaultUWSErrorWriter implements ServiceErrorWriter { if (acceptHeader != null && !acceptHeader.trim().isEmpty()){ // Parse the given MIME types list: AcceptHeader accept = new AcceptHeader(acceptHeader); - ArrayList<String> lstMimeTypes = accept.getOrderedMimeTypes(); + List<String> lstMimeTypes = accept.getOrderedMimeTypes(); for(String acceptedFormat : lstMimeTypes){ for(String f : managedFormats){ if (acceptedFormat.equalsIgnoreCase(f)) diff --git a/src/uws/service/file/LocalUWSFileManager.java b/src/uws/service/file/LocalUWSFileManager.java index 0bbb628..080b80d 100644 --- a/src/uws/service/file/LocalUWSFileManager.java +++ b/src/uws/service/file/LocalUWSFileManager.java @@ -16,7 +16,7 @@ package uws.service.file; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. 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) */ @@ -38,6 +38,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; +import java.util.List; import java.util.NoSuchElementException; import uws.UWSException; @@ -69,7 +70,7 @@ import uws.service.request.UploadFile; * </p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (02/2015) + * @version 4.2 (09/2017) */ public class LocalUWSFileManager implements UWSFileManager { @@ -417,7 +418,7 @@ public class LocalUWSFileManager implements UWSFileManager { /** * Create a File instance from the given upload file description. - * This function is able to deal with location as URI and as file path. + * This function is able to deal with location as URI and as file path. * * @param upload Description of an uploaded file. * @@ -765,7 +766,7 @@ public class LocalUWSFileManager implements UWSFileManager { itBackupFiles = loadAllBackupFiles().iterator(); } - private ArrayList<File> loadAllBackupFiles(){ + private List<File> loadAllBackupFiles(){ ArrayList<File> backupFiles = new ArrayList<File>(); // If there must be 1 directory by user: diff --git a/test/adql/query/TestADQLObjectPosition.java b/test/adql/query/TestADQLObjectPosition.java index 7a41bb2..a03b24c 100644 --- a/test/adql/query/TestADQLObjectPosition.java +++ b/test/adql/query/TestADQLObjectPosition.java @@ -3,17 +3,14 @@ package adql.query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.junit.Before; import org.junit.Test; import adql.parser.ADQLParser; import adql.parser.ParseException; -import adql.query.ADQLObject; -import adql.query.ADQLQuery; -import adql.query.TextPosition; import adql.query.constraint.Comparison; import adql.query.from.ADQLJoin; import adql.query.from.ADQLTable; @@ -75,7 +72,7 @@ public class TestADQLObjectPosition { * the one of the first table of the clause FROM. */ assertEquality(new TextPosition(1, 26, 1, 49), query.getFrom().getPosition()); // Test ADQLTable - ArrayList<ADQLTable> tables = query.getFrom().getTables(); + List<ADQLTable> tables = query.getFrom().getTables(); assertEquality(new TextPosition(1, 26, 1, 29), tables.get(0).getPosition()); assertEquality(new TextPosition(1, 35, 1, 38), tables.get(1).getPosition()); // Test the join condition: -- GitLab