From 510217ad16772a5d97c6fdf9196cf994811647f7 Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Wed, 9 Apr 2014 17:09:35 +0200 Subject: [PATCH] ADQL: Use addMatch(...) function also for the root search object in SimpleSearchHandler. Becareful with the function addMatch(ADQLObject, ADQLIterator): the iterator may be null if the match to add is the root search object itself! No modification needed in SimpleReplaceHandler: Null test already done :-) ! --- src/adql/search/SimpleSearchHandler.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/adql/search/SimpleSearchHandler.java b/src/adql/search/SimpleSearchHandler.java index d7305e6..05c0e7a 100644 --- a/src/adql/search/SimpleSearchHandler.java +++ b/src/adql/search/SimpleSearchHandler.java @@ -16,7 +16,8 @@ package adql.search; * 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-2014 - UDS/Centre de DonnĂ©es astronomiques de Strasbourg (CDS), + * Astronomisches Rechen Institut (ARI) */ import java.util.ArrayList; @@ -35,8 +36,8 @@ import adql.query.ADQLQuery; * <li>The matching objects are simply collected in an ArrayList.</li> * </ul> * - * @author Grégory Mantelet (CDS) - * @version 06/2011 + * @author Grégory Mantelet (CDS;ARI) + * @version 1.2 (12/2013) * * @see SearchColumnHandler */ @@ -119,10 +120,12 @@ public abstract class SimpleSearchHandler implements ISearchHandler { this.firstMatch = firstMatch; } + @Override public final Iterator<ADQLObject> iterator(){ return results.iterator(); } + @Override public final int getNbMatch(){ return results.size(); } @@ -152,6 +155,8 @@ public abstract class SimpleSearchHandler implements ISearchHandler { /** * Adds the given ADQL object as one result of the research. * + * <p><b><u>Warning:</u> the second parameter (<i>it</i>) may be <i>null</i> if the given match is the root search object itself.</b></p> + * * @param matchObj An ADQL object which has matched to the research criteria. * @param it The iterator from which the matched ADQL object has been extracted. */ @@ -167,14 +172,16 @@ public abstract class SimpleSearchHandler implements ISearchHandler { results.clear(); } + @Override public final void search(final ADQLObject startObj){ reset(); if (startObj == null) return; + // Test the root search object: if (match(startObj)) - results.add(startObj); + addMatch(startObj, null); Stack<ADQLIterator> stackIt = new Stack<ADQLIterator>(); ADQLObject obj = null; -- GitLab