Skip to content

Instantly share code, notes, and snippets.

@dalmat36
Created April 9, 2015 16:01
Show Gist options
  • Select an option

  • Save dalmat36/73d2b93d026b4cb237de to your computer and use it in GitHub Desktop.

Select an option

Save dalmat36/73d2b93d026b4cb237de to your computer and use it in GitHub Desktop.
This code snippet creates and abstract indexed collection handler. This enables you to use Commons DBUtils to return a result from a database as a CQEngine indexed collection.
public abstract class AbstractIndexedCollectionHandler<T> implements ResultSetHandler<IndexedCollection<T>> {
public IndexedCollection<T> handle(ResultSet rs) throws SQLException {
IndexedCollection<T> rows = CQEngine.newInstance();
while (rs.next()) {
rows.add(this.handleRow(rs));
}
return rows;
}
protected abstract T handleRow(ResultSet rs) throws SQLException;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment