private boolean isOnValidRow() { return result.getRowId() >= 0 && !result.isAfterLast(); }
private void patchCurrentRow(Value[] row) { boolean changed = false; Value[] current = result.currentRow(); CompareMode mode = conn.getCompareMode(); for (int i = 0; i < row.length; i++) { if (row[i].compareTo(current[i], mode) != 0) { changed = true; break; } } if (patchedRows == null) { patchedRows = new HashMap<>(); } Integer rowId = result.getRowId(); if (!changed) { patchedRows.remove(rowId); } else { patchedRows.put(rowId, row); } }
/** * INTERNAL * * @param columnIndex * index of a column * @return internal representation of the value in the specified column */ public Value get(int columnIndex) { checkColumnIndex(columnIndex); checkOnValidRow(); Value[] list; if (patchedRows == null) { list = result.currentRow(); } else { list = patchedRows.get(result.getRowId()); if (list == null) { list = result.currentRow(); } } Value value = list[columnIndex - 1]; wasNull = value == ValueNull.INSTANCE; return value; }
/** * Checks if the current position is row 1, that means next() was called * once and returned true. * * @return if the current position is the first row * @throws SQLException if the result set is closed */ @Override public boolean isFirst() throws SQLException { try { debugCodeCall("isFirst"); checkClosed(); return result.getRowId() == 0 && !result.isAfterLast(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Checks if the current position is after the last row, that means next() * was called and returned false, and there was at least one row. * * @return if there are results and the current position is after the last * row * @throws SQLException if the result set is closed */ @Override public boolean isAfterLast() throws SQLException { try { debugCodeCall("isAfterLast"); checkClosed(); return result.getRowId() > 0 && result.isAfterLast(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Checks if the current position is before the first row, that means next() * was not called yet, and there is at least one row. * * @return if there are results and the current position is before the first * row * @throws SQLException if the result set is closed */ @Override public boolean isBeforeFirst() throws SQLException { try { debugCodeCall("isBeforeFirst"); checkClosed(); return result.getRowId() < 0 && result.hasNext(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Moves the current position to before the first row, that means resets the * result set. * * @throws SQLException if the result set is closed */ @Override public void beforeFirst() throws SQLException { try { debugCodeCall("beforeFirst"); checkClosed(); if (result.getRowId() >= 0) { resetResult(); } } catch (Exception e) { throw logAndConvert(e); } }
/** * Gets the current row number. The first row is row 1, the second 2 and so * on. This method returns 0 before the first and after the last row. * * @return the row number */ @Override public int getRow() throws SQLException { try { debugCodeCall("getRow"); checkClosed(); if (result.isAfterLast()) { return 0; } int rowId = result.getRowId(); return rowId + 1; } catch (Exception e) { throw logAndConvert(e); } }
/** * Checks if the current position is the last row, that means next() was * called and did not yet returned false, but will in the next call. * * @return if the current position is the last row * @throws SQLException if the result set is closed */ @Override public boolean isLast() throws SQLException { try { debugCodeCall("isLast"); checkClosed(); int rowId = result.getRowId(); return rowId >= 0 && !result.isAfterLast() && !result.hasNext(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Moves the current position to the first row. This is the same as calling * beforeFirst() followed by next(). * * @return true if there is a row available, false if not * @throws SQLException if the result set is closed */ @Override public boolean first() throws SQLException { try { debugCodeCall("first"); checkClosed(); if (result.getRowId() >= 0) { resetResult(); } return nextRow(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Moves the current position to a specific row relative to the current row. * * @param rowCount 0 means don't do anything, 1 is the next row, -1 the * previous. If the value is too large, the position is moved * after the last row, if if the value is too small it is moved * before the first row. * @return true if there is a row available, false if not * @throws SQLException if the result set is closed */ @Override public boolean relative(int rowCount) throws SQLException { try { debugCodeCall("relative", rowCount); checkClosed(); if (rowCount < 0) { rowCount = result.getRowId() + rowCount + 1; resetResult(); } for (int i = 0; i < rowCount; i++) { if (!nextRow()) { return false; } } return isOnValidRow(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Checks if the current position is before the first row, that means next() * was not called yet. * * @return if the current position is before the first row * @throws SQLException if the result set is closed */ public boolean isBeforeFirst() throws SQLException { try { debugCodeCall("isBeforeFirst"); checkClosed(); return result.getRowId() < 0; } catch (Throwable e) { throw logAndConvert(e); } }
private Value get(int columnIndex) { checkColumnIndex(columnIndex); checkOnValidRow(); Value[] list; if (patchedRows == null) { list = result.currentRow(); } else { list = patchedRows.get(result.getRowId()); if (list == null) { list = result.currentRow(); } } Value value = list[columnIndex - 1]; wasNull = value == ValueNull.INSTANCE; return value; }
private Value get(int columnIndex) { checkColumnIndex(columnIndex); checkOnValidRow(); Value[] list; if (patchedRows == null) { list = result.currentRow(); } else { list = patchedRows.get(result.getRowId()); if (list == null) { list = result.currentRow(); } } Value value = list[columnIndex - 1]; wasNull = value == ValueNull.INSTANCE; return value; }
/** * Checks if the current position is row 1, that means next() was called * once and returned true. * * @return if the current position is the first row * @throws SQLException if the result set is closed */ public boolean isFirst() throws SQLException { try { debugCodeCall("isFirst"); checkClosed(); int row = result.getRowId(); return row == 0 && row < result.getRowCount(); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Checks if the current position is the last row, that means next() was * called and did not yet returned false, but will in the next call. * * @return if the current position is the last row * @throws SQLException if the result set is closed */ public boolean isLast() throws SQLException { try { debugCodeCall("isLast"); checkClosed(); int row = result.getRowId(); return row >= 0 && row == result.getRowCount() - 1; } catch (Throwable e) { throw logAndConvert(e); } }