Java Reference
In-Depth Information
private static final int CHARACTERISTICS =
Spliterator.IMMUTABLE | Spliterator.NONNULL;
private final ResultSet resultSet;
private final AutoCloseable[] toClose;
* Constructor.
* @param resultSet The result set to process; may not be {@code null}.
* @param additionalCharacteristics relevant characteristics beyond
* {@link java.util.Spliterator#IMMUTABLE}
* and {@link java.util.Spliterator#NONNULL},
* or {@code 0} if none
* @param toClose Optional additional autocloseables (such as
* {@link java.sql.Connection}) to close when the result
* set is exhausted; may be {@code null}
* (equivalent to empty).
public ResultSetSpliterator(
final ResultSet resultSet, final int additionalCharacteristics,
final AutoCloseable… toClose
) {
super(Long.MAX_VALUE, CHARACTERISTICS | additionalCharacteristics);
Objects.requireNonNull(resultSet, "result set");
this.resultSet = resultSet;
if (toClose == null) {
this.toClose = new AutoCloseable[0];
} else {
this.toClose = toClose;
* Given a {@link ResultSet} instance on a current row, return a
* {@code RESULT_T} instance for that row.
* This code should not call {@link java.sql.ResultSet#next()} or
* otherwise mutate the result set: it should
* be treated as read-only.
* @param resultSet The result set to load.
* @return The result instance.
* @throws SQLException If an error occurs.
protected abstract RESULT_T processRow(ResultSet resultSet)
throws SQLException;
* If a remaining element exists, performs the given action on it,
* returning {@code true}; else returns {@code false}. If this
* Spliterator is {@link #ORDERED} the action is performed on the
* next element in encounter order. Exceptions thrown by the
Search WWH ::

Custom Search