org.semanticweb.kaon2.api
Interface Cursor<E>


public interface Cursor<E>

This interface enables sequential access to a result set of a search. After creation, the cursor is before the first object, i.e. next() should be called before calling currentObject(). A cursor should be closed after usage, otherwise resource leak is risked. Opening a cursor locks the connection for reading. Cursors are not thread-safe objects; for accessing objects from different threads, open seperate cursors.


Method Summary
 void close()
          Closes the cursor and releases all resources used.
 boolean hasNext()
          Returns true if there are more objects in the cursor, i.e.
 boolean isOpen()
          Returns true if the cursor is open.
 E next()
          Returns the current objects and moves the cursor to the next object.
 int size()
          Returns the number of objects in the cursor.
 

Method Detail

isOpen

boolean isOpen()
               throws KAON2Exception
Returns true if the cursor is open.

Returns:
true if the cursor is open
Throws:
KAON2Exception - thrown if there is an error

size

int size()
         throws KAON2Exception
Returns the number of objects in the cursor.

Returns:
the number of objects in the cursor
Throws:
KAON2Exception - thrown if there is an error

next

E next()
       throws KAON2Exception
Returns the current objects and moves the cursor to the next object. If there is no current object, an exception is thrown.

Returns:
the current object
Throws:
KAON2Exception - thrown if there is an error (e.g. there is no next object)

hasNext

boolean hasNext()
                throws KAON2Exception
Returns true if there are more objects in the cursor, i.e. if next() can safely be called without returning an error.

Returns:
true if there are more objects in the cursor
Throws:
KAON2Exception - thrown if there is an error

close

void close()
           throws KAON2Exception
Closes the cursor and releases all resources used.

Throws:
KAON2Exception - thrown if there is an error