@ Override public boolean relative ( int rows ) throws SQLException { checkClosed ( ) ; if ( rowCount == 0 ) { return false ; } if ( cursorPosition == Position . afterLast && rows > 0 ) { return false ; } if ( cursorPosition == Position . beforeFirst && rows <= 0 ) { return false ; } if ( table . getActiveRowIndex ( ) + rows >= rowCount ) { cursorPosition = Position . afterLast ; if ( table . getActiveRowIndex ( ) + rows == rowCount ) { return true ; } return false ; } try { // for negative row numbers, resetRowPosition method is called // and the cursor advances to the desired row from top of the table int rowsToMove = table . getActiveRowIndex ( ) + rows ; if ( cursorPosition == Position . beforeFirst || rows < 0 ) { if ( cursorPosition == Position . afterLast ) { rowsToMove = rowCount + rows ; } else if ( cursorPosition == Position . beforeFirst ) { rowsToMove = rows - 1 ; } else { rowsToMove = table . getActiveRowIndex ( ) + rows ; } if ( rowsToMove < 0 ) { beforeFirst ( ) ; return false ; } table . resetRowPosition ( ) ; table . advanceToRow ( 0 ) ; } cursorPosition = Position . middle ; return table . advanceToRow ( rowsToMove ) ; } catch ( Exception x ) { throw SQLError . get ( x ) ; } }
Moves the cursor a relative number of rows either positive or negative .