gishur.core
Interface Cursor

All Superinterfaces:
java.util.Enumeration
All Known Implementing Classes:
CursorAdapter

public interface Cursor
extends java.util.Enumeration

The interface defining the basic functionality of a Cursor. There are methods declared for arbitrarily moving over a list-like structure and for access to the underlying structure, e.g element() and length(). A Cursor implements the Enumeration interface, so one can use Cursors as Enumerations too. In order to use this correctly, the default constructor of the Cursor should set it to the first element.

Version:
1.1
Author:
Thomas Wolf

Method Summary
 void bottom()
          Sets the Cursor to the last element.
 java.lang.Object element()
          Returns the element to which this Cursor points at the moment.
 java.lang.Object getBookmark()
          Returns a bookmark-object.
 void invalidate()
          Sets the Cursor to an invalid position.
 int length()
          Returns the number of elements in the underlying structure of this Cursor.
 void next()
          Moves the Cursor on to the next position in forward direction.
 void next(int step)
          Moves the Cursor step elements in forward direction.
 void prev()
          Moves the Cursor on to the next position in backward direction.
 void prev(int step)
          Moves the Cursor step elements in backward direction.
 void relative(int step)
          Moves the Cursor step positions within the underlying structure.
 void set(int index)
          Sets the Cursor to the index-th position from the first element.
 void set(java.lang.Object bookmark)
          Sets the cursor to a bookmarked position.
 void top()
          Sets the Cursor to the first element.
 boolean valid()
          Checks if the Cursor's actual position is valid.
 
Methods inherited from interface java.util.Enumeration
hasMoreElements, nextElement
 

Method Detail

element

public java.lang.Object element()
Returns the element to which this Cursor points at the moment.
Returns:
the element "under" the Cursor

relative

public void relative(int step)
Moves the Cursor step positions within the underlying structure.
Parameters:
step - the number of elements to move

valid

public boolean valid()
Checks if the Cursor's actual position is valid.
Returns:
true, if the Cursor points to a valid position, and false otherwise

invalidate

public void invalidate()
Sets the Cursor to an invalid position.

length

public int length()
Returns the number of elements in the underlying structure of this Cursor.
Returns:
the number of elements in the underlying structure

top

public void top()
Sets the Cursor to the first element.

bottom

public void bottom()
Sets the Cursor to the last element.

next

public void next(int step)
Moves the Cursor step elements in forward direction.
Parameters:
step - the number+1 of elements to skip in forward direction

prev

public void prev(int step)
Moves the Cursor step elements in backward direction.
Parameters:
step - the number+1 of elements to skip in backward direction

next

public void next()
Moves the Cursor on to the next position in forward direction.

prev

public void prev()
Moves the Cursor on to the next position in backward direction.

set

public void set(int index)
Sets the Cursor to the index-th position from the first element.
Parameters:
index - the index-th element starting with the first one will be the Cursor's new position

getBookmark

public java.lang.Object getBookmark()
Returns a bookmark-object. If this function is not supported, a FunctionNotSupportedException will be thrown.
Returns:
a bookmark-object.
See Also:
set(int)

set

public void set(java.lang.Object bookmark)
Sets the cursor to a bookmarked position. If this function is not supported, a FunctionNotSupportedException will be thrown.
Parameters:
bookmark - a bookmark-object
See Also:
getBookmark()