com.clarkparsia.pellet.sparqldl.engine.NoReorderingQueryPlan Maven / Gradle / Ivy
// Copyright (c) 2006 - 2008, Clark & Parsia, LLC.
// This source code is available under the terms of the Affero General Public License v3.
//
// Please see LICENSE.txt for full license terms, including the availability of proprietary exceptions.
// Questions, comments, or requests for clarification: [email protected]
package com.clarkparsia.pellet.sparqldl.engine;
import com.clarkparsia.pellet.sparqldl.model.Query;
import com.clarkparsia.pellet.sparqldl.model.QueryAtom;
import com.clarkparsia.pellet.sparqldl.model.ResultBinding;
/**
*
* Title: Query Plan that returns the atoms in the order as they appear in the query.
*
*
* Description:
*
*
* Copyright: Copyright (c) 2007
*
*
* Company: Clark & Parsia, LLC.
*
*
* @author Petr Kremen
*/
public class NoReorderingQueryPlan extends QueryPlan {
private int index;
private int size;
public NoReorderingQueryPlan(Query query) {
super(query);
index = 0;
size = query.getAtoms().size();
}
@Override
public QueryAtom next(ResultBinding binding) {
return query.getAtoms().get(index++).apply(binding);
}
@Override
public boolean hasNext() {
return index < size;
}
@Override
public void back() {
index--;
}
@Override
public void reset() {
index = 0;
}
}