
dk.eobjects.metamodel.data.MaxRowsDataSetStrategyWrapper Maven / Gradle / Ivy
/**
* This file is part of MetaModel.
*
* MetaModel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MetaModel 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MetaModel. If not, see .
*/
package dk.eobjects.metamodel.data;
import dk.eobjects.metamodel.MetaModelException;
import dk.eobjects.metamodel.query.SelectItem;
/**
* Wraps another DataSet and simply adds a maximum number of rows constraint
*/
public class MaxRowsDataSetStrategyWrapper implements IDataSetStrategy {
private DataSet _dataSet;
private int _rowsLeft;
public MaxRowsDataSetStrategyWrapper(DataSet dataSet, int maxRows) {
_dataSet = dataSet;
_rowsLeft = maxRows;
}
public void close() {
_dataSet.close();
}
public Row getRow() throws MetaModelException {
return _dataSet.getRow();
}
public SelectItem[] getSelectItems() {
return _dataSet.getSelectItems();
}
public boolean next() {
if (_rowsLeft > 0) {
boolean next = _dataSet.next();
if (next) {
_rowsLeft--;
}
return next;
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy