/** Reset this result set back to the beginning */ public void rewind( ) { reset() ; }
public ResultSetMem() { this.varNames = new ArrayList<>(); reset(); }
/** * Create an in-memory result set from another one * * @param imrs2 * The other ResultSetMem object * @param takeCopy * Should we copy the rows? */ public ResultSetMem(ResultSetMem imrs2, boolean takeCopy) { varNames = imrs2.varNames; if ( takeCopy ) rows.addAll(imrs2.rows); else // Share results (not the iterator). rows = imrs2.rows; reset(); }
/** * Create an in-memory result set from an array of ResulSets. It is assumed * that all the ResultSets from the array have the same variables. * * @param sets * the ResultSet objects to concatenate. */ public ResultSetMem(ResultSet... sets) { varNames = sets[0].getResultVars(); for ( ResultSet rs : sets ) { if ( !varNames.equals(rs.getResultVars()) ) throw new ResultSetException("ResultSet must have the same variables."); if ( rs instanceof ResultSetMem ) rows.addAll(((ResultSetMem)rs).rows); else while (rs.hasNext()) rows.add(rs.nextBinding()); } reset(); }
/** * Create an in-memory result set from any ResultSet object. If the * ResultSet is an in-memory one already, then no copying is done - the * necessary internal datastructures are shared. This operation destroys * (uses up) a ResultSet object that is not an in-memory one. */ public ResultSetMem(ResultSet qr) { model = qr.getResourceModel(); if ( qr instanceof ResultSetMem ) { ResultSetMem qrm = (ResultSetMem)qr; this.rows = qrm.rows; this.varNames = qrm.varNames; } else { varNames = qr.getResultVars(); List<Var> vars = Var.varList(varNames); while (qr.hasNext()) { Binding rb = BindingFactory.copy(qr.nextBinding()); rows.add(rb); } } reset(); }