IterableDataModel is an
implementation of DataModel that wraps an Iterable.
This can be used to encapsulate nearly every collection type, including
Collection derived types such as List and Set.
As such this specific DataModel can be used instead of more specific
DataModels like ListDataModel and CollectionDataModel.
| Modifier and Type | Field and Description |
|---|---|
| private int | index
The current row index. |
| private Iterable | iterable
The iterable that this data model is primarily wrapping. |
| private List | list
A list that's optionally used to hold and cache data collected from the iterable that this data model is wrapping. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | IterableDataModel(Iterable<E>
Iterable to be wrapped. iterable)Construct a new |
| Modifier and Type | Method and Description |
|---|---|
| public int | getRowCount()
Implements abstract javax. Return the number of rows of data objects represented by this
|
| public E | getRowData()
Implements abstract javax. Return an object representing the data for the currenty selected row index. |
| private E | Returns: data for the currently selected row index, or null if there's no dataReturn an object representing the data for the currently selected row index. |
| public int | getRowIndex()
Implements abstract javax. Return the zero-relative index of the currently selected row. |
| public Object | getWrappedData()
Implements abstract javax. Return the object representing the data wrapped by this
|
| public boolean | isRowAvailable()
Implements abstract javax. Return a flag indicating whether there is |
| private static < The generic iterable element type. E> List | Returns: The list representation of the given iterable, possibly the same instance as that iterable.The iterable to be converted. iterable)Converts an iterable into a list. |
| private void | notifyListeners(int
the previous index oldRowIndex, int The current zero-relative index (must be non-negative) rowIndex)Notifies all DataModelListeners |
| public void | setRowIndex(int
The new zero-relative index (must be non-negative) rowIndex)Implements abstract javax. Set the zero-relative index of the currently selected row, or -1 to indicate that we are not positioned on a row. |
| public void | setWrappedData(Object
Data collection to be wrapped, or data)null to
detach from any previous data collectionImplements abstract javax. Set the object representing the data collection wrapped by this
|
| index | back to summary |
|---|---|
| private int index The current row index. | |
| iterable | back to summary |
|---|---|
| private Iterable<E> iterable The iterable that this data model is primarily wrapping. | |
| list | back to summary |
|---|---|
| private List<E> list A list that's optionally used to hold and cache data collected from the iterable that this data model is wrapping. | |
| IterableDataModel | back to summary |
|---|---|
| public IterableDataModel() Construct a new | |
| IterableDataModel | back to summary |
|---|---|
| public IterableDataModel(Iterable<E> iterable) Construct a new
| |
| getRowCount | back to summary |
|---|---|
| public int getRowCount() Implements abstract javax. Return the number of rows of data objects represented by this
| |
| getRowData | back to summary |
|---|---|
| public E getRowData() Implements abstract javax. Return an object representing the data for the currenty selected
row index. If no
| |
| getRowDataOrNull | back to summary |
|---|---|
| private E getRowDataOrNull() Return an object representing the data for the currently selected
row index. If either no
| |
| getRowIndex | back to summary |
|---|---|
| public int getRowIndex() Implements abstract javax. Return the zero-relative index of the currently selected row. If
we are not currently positioned on a row, or no
| |
| getWrappedData | back to summary |
|---|---|
| public Object getWrappedData() Implements abstract javax. Return the object representing the data wrapped by this
| |
| isRowAvailable | back to summary |
|---|---|
| public boolean isRowAvailable() Implements abstract javax. Return a flag indicating whether there is
| |
| iterableToList | back to summary |
|---|---|
| private static <E> List Converts an iterable into a list. This method makes NO guarantee to whether changes to the source iterable are reflected in the returned list or not. For instance if the given iterable already is a list, it's returned directly. | |
| notifyListeners | back to summary |
|---|---|
| private void notifyListeners(int oldRowIndex, int rowIndex) Notifies all DataModelListeners
| |
| setRowIndex | back to summary |
|---|---|
| public void setRowIndex(int rowIndex) Implements abstract javax. Set the zero-relative index of the currently selected row, or -1
to indicate that we are not positioned on a row. It is
possible to set the row index at a value for which the underlying data
collection does not contain any row data. Therefore, callers may
use the If there is no
| |
| setWrappedData | back to summary |
|---|---|
| public void setWrappedData(Object data) Implements abstract javax. Set the object representing the data collection wrapped by this
If
| |