org.integratedmodelling.engine.kbox.sql.h2.H2Result Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright (C) 2007, 2015:
*
* - Ferdinando Villa
* - integratedmodelling.org
* - any other authors listed in @author annotations
*
* All rights reserved. This file is part of the k.LAB software suite,
* meant to enable modular, collaborative, integrated
* development of interoperable data and model components. For
* details, see http://integratedmodelling.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Affero General Public License
* Version 3 or any later version.
*
* This program 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
* Affero General Public License for more details.
*
* You should have received a copy of the Affero General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* The license is also available at: https://www.gnu.org/licenses/agpl.html
*******************************************************************************/
package org.integratedmodelling.engine.kbox.sql.h2;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.integratedmodelling.api.monitoring.IMonitor;
import org.integratedmodelling.collections.ImmutableList;
import org.integratedmodelling.common.utils.MatchedSorter;
/**
* List to return results of a NeoKBox query. Only stores object IDs, creating
* any object lazily.
*
* Allows specifying a sorting score from outside for each result. If the scores
* are given, iteration will be in descending score order. Scores are doubles and
* expected to be 0-1; the default value of a score when only some are specified
* is 0.
*
* @author Ferd
*
*/
public class H2Result extends ImmutableList /* implements SQL.ResultHandler */ {
List results;
H2Kbox kbox;
IMonitor monitor;
Class cls;
class KboxIterator implements Iterator {
int idx = 0;
@Override
public boolean hasNext() {
return idx < results.size();
}
@Override
public T next() {
return (T)get(idx++);
}
@Override
public void remove() {
throw new UnsupportedOperationException("cannot modify read-only kbox iterator");
}
}
public H2Result(H2Kbox kbox, List res, List