com.sun.lwuit.list
Interface ListModel

All Known Implementing Classes:
DefaultListModel

public interface ListModel

Represents the data structure of the list, thus allowing a list to represent any potential data source by referencing different implementations of this interface. E.g. a list model can be implemented in such a way that it retrieves data directly from storage (although caching would be recommended).

It is the responsibility of the list to notify observers (specifically the view List of any changes to its state (items removed/added/changed etc.) thus the data would get updated on the view.


Method Summary
 void addDataChangedListener(DataChangedListener l)
          Invoked to indicate interest in future change events
 void addItem(java.lang.Object item)
          Adds the specified item to the end of this list.
 void addSelectionListener(SelectionListener l)
          Invoked to indicate interest in future selection events
 java.lang.Object getItemAt(int index)
          Returns the item at the given offset
 int getSelectedIndex()
          Returns the selected list offset
 int getSize()
          Returns the number of items in the list
 void removeDataChangedListener(DataChangedListener l)
          Invoked to indicate no further interest in future change events
 void removeItem(int index)
          Removes the item at the specified position in this list.
 void removeSelectionListener(SelectionListener l)
          Invoked to indicate no further interest in future selection events
 void setSelectedIndex(int index)
          Sets the selected list offset can be set to -1 to clear selection
 

Method Detail

getItemAt

java.lang.Object getItemAt(int index)
Returns the item at the given offset

Parameters:
index - an index into this list
Returns:
the item at the specified index

getSize

int getSize()
Returns the number of items in the list

Returns:
the number of items in the list

getSelectedIndex

int getSelectedIndex()
Returns the selected list offset

Returns:
the selected list index

setSelectedIndex

void setSelectedIndex(int index)
Sets the selected list offset can be set to -1 to clear selection

Parameters:
index - an index into this list

addDataChangedListener

void addDataChangedListener(DataChangedListener l)
Invoked to indicate interest in future change events

Parameters:
l - a data changed listener

removeDataChangedListener

void removeDataChangedListener(DataChangedListener l)
Invoked to indicate no further interest in future change events

Parameters:
l - a data changed listener

addSelectionListener

void addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events

Parameters:
l - a selection listener

removeSelectionListener

void removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events

Parameters:
l - a selection listener

addItem

void addItem(java.lang.Object item)
Adds the specified item to the end of this list. An optional operation for mutable lists, it can throw an unsupported operation exception if a list model is not mutable.

Parameters:
item - the item to be added

removeItem

void removeItem(int index)
Removes the item at the specified position in this list.

Parameters:
index - the index of the item to removed