/** * Constructs a wrapper for the specified {@code resultSet}. * * @param resultSet * the result set to wrap. */ public ResultSetMemWrapper(ResultSet resultSet) { super(new ResultSetMem(resultSet)); }
/** Moves onto the next result possibility. * The returned object should be of class QuerySolution */ @Override public QuerySolution next() { return nextSolution() ; }
/** Reset this result set back to the beginning */ public void rewind( ) { reset() ; }
/** Moves onto the next result possibility. */ @Override public QuerySolution nextSolution() { return new ResultBinding(model, nextBinding()) ; }
@Override public QuerySolution peek() { return new ResultBinding(model, peekBinding()); }
/** Moves onto the next result possibility. */ public QuerySolution nextSolution() { return new ResultBinding(model, nextBinding()) ; }
/** * Take a copy of a result set - the result set returns is an in-memory * copy. It is not attached to the original query execution object which can * be closed. * * @param results * @return ResultSet */ static public ResultSetRewindable copyResults(ResultSet results) { return new ResultSetMem(results); }
/** Reset this result set back to the beginning */ public void rewind( ) { reset() ; }
/** Moves onto the next result possibility. * The returned object should be of class QuerySolution */ public QuerySolution next() { return nextSolution() ; }
/** Take a copy of a result set - the result set returns is an in-memory copy. * It is not attached to the original query execution object which can be closed. * @param results * @return ResultSet */ static public ResultSetRewindable copyResults(ResultSet results) { return new ResultSetMem(results) ; }
public ResultSetMem() { this.varNames = new ArrayList<String>() ; reset() ; }
/** * Constructs a wrapper for the specified {@code resultSet}. * * @param resultSet * the result set to wrap. */ public ResultSetWrapper(ResultSet resultSet) { // puts the content of the resultset into memory if the specified // resultset is not an in-memory resultset. super(new ResultSetMem(resultSet)); }
public ResultSetMem() { this.varNames = new ArrayList<String>() ; 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 ResultSets to concatenate. */ public static ResultSet union(ResultSet... sets) { return new ResultSetMem(sets); }
/** 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() ; }
/** Turn an existing result set into a rewindable one. * May take a copy - uses up the result set passed in. * @param resultSet * @return ResultSetRewindable */ static public ResultSetRewindable makeRewindable(ResultSet resultSet) { return new ResultSetMem(resultSet) ; }
/** 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() ; }
/** * Turn an existing result set into a rewindable one. * May take a copy but this is not guarantted * Uses up the result set passed in which is no longer valid as a ResultSet. * * @param resultSet * @return ResultSetRewindable */ static public ResultSetRewindable makeRewindable(ResultSet resultSet) { if ( resultSet instanceof ResultSetRewindable ) { ResultSetRewindable rsw = (ResultSetRewindable)resultSet ; rsw.reset() ; return rsw ; } return new ResultSetMem(resultSet); }
/** 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(); }
ResultSetRewindable resultSetRewindable = new ResultSetMem(resultSet) ;