Interface CursorExt

All Superinterfaces:
Cursor

public interface CursorExt extends Cursor

Optional cursor capabilities, in the same spirit as RowExt.

These are not on Cursor itself because that interface is public and is implemented outside this repository; adding a method to it would break every third party library that provides one. Reach these through the static helpers on Database, which degrade gracefully on a cursor that does not implement this interface:

Database.beforeFirst(cursor);
int rows = Database.count(cursor); // -1 when the port cannot say cheaply

Every cursor returned by a Codename One port implements this.

  • Method Details

    • beforeFirst

      void beforeFirst() throws IOException

      Rewinds to before the first row, without landing on a row.

      After this call Cursor#getPosition() reports -1 and Cursor#getRow() throws, exactly as on a freshly returned cursor. This is the operation Cursor#position(int) performs when given -1.

      Throws
      • IOException: if the cursor is closed or the rewind fails
      Throws:
      IOException
    • getCount

      int getCount() throws IOException

      Returns the number of rows in the result set, or -1 when the port cannot determine it without walking the whole set.

      Ports that already track the count report it directly. Ports backed by a forward-only statement have to step to the end and rewind, so they report the count once it is known and -1 before that. Treat -1 as "unknown", not as "empty".

      Returns

      the row count, or -1 when it is not cheaply available

      Throws
      • IOException: if the cursor is closed
      Throws:
      IOException