public interface IListDatasource extends IDatasource
IListDatasource
extends IDatasource
for management of
list (index) based data models. This is the base used for ListView
objects. Each index in the IListDatasource
represents one row in
the ListView
.
Currently JSONDatasource
is the only available implementation. You
can use AbstractListDatasource
as abstract base implementation to
extend for your own needs.
Modifier and Type | Method and Description |
---|---|
void |
addElement(java.lang.Object object)
Add a new object to the data model.
|
void |
addElementAtIndex(java.lang.Object object,
int index)
Insert a new object to the data model at the given row index.
|
void |
addElements(java.util.Vector objects)
Add multiple new objects to the data model.
|
IComparator |
getComparator()
Use this method to get the current
IComparator used by the
ListView . |
java.lang.Object |
getElementAtIndex(int index)
Call this method to get the object of the data model at a given index.
|
java.util.Vector |
getElements()
Call this method to get all objects in the data model managed by this
datasource.
|
DatasourceException |
getException()
Use this method to get the last exception that has been caught while
reloading the datasource.
|
java.lang.Object |
getExpressionValue(java.lang.String relativeExpression,
int elementIndex)
This method to get the object of the data model using an expression that
is relative to on object in the data model with the given row index.
|
java.util.Vector |
getFilteredElements()
Returns all elements matching the
getFilterExpression() . |
java.lang.String |
getFilterExpression()
Returns the filter expression currently used.
|
int |
getNumberOfElements()
Call this method to get the total number of objects in the data model
managed by this datasource.
|
java.lang.Object |
getSelectedElement()
Returns the currently selected object of the
ListView or
null if no object was set as selected. |
boolean |
hasException()
Use this method to check for exceptions that might have been caught while
reloading the datasource.
|
boolean |
isFilteredElement(java.lang.Object object)
Returns
true if the given object matches the filter for this
datasource returned by getFilterExpression() . |
void |
reloadElements()
Use to reload the objects managed by the datasource.
|
void |
removeAllElements()
Removes all objects from the data model.
|
void |
removeElement(java.lang.Object object)
Remove the given object from the data model.
|
void |
removeElementAtIndex(int index)
Remove the object at the given index of the data model.
|
void |
resort()
Call this method to manually resort the contents of the data model.
|
void |
setComparator(IComparator comparator)
Use this method to set a
IComparator implementation to be used
when sorting or resort ing the data model represention in the
ListView . |
void |
setElements(java.util.Vector objects)
Set the elements managed by the datasource to the given
Vector of objects. |
void |
setFilterExpression(java.lang.String filter)
Use this method to set a filter expression and enable filtering for the
datasource.
|
void |
setSelectedElement(java.lang.Object object)
Set the object selected by the
ListView . |
getExpressionValue
java.lang.Object getExpressionValue(java.lang.String relativeExpression, int elementIndex) throws java.lang.Exception
IDatasource
implementation
uses to reference an object.expression
- String that references an object in the data modelelementIndex
- the index of the object to be used to evaluate the given
expressionnull
if there
was no objectjava.lang.Exception
- if an error occured evaluating the given expressionvoid reloadElements()
int getNumberOfElements()
java.util.Vector getElements()
Vector
returned will not change the
contents of the data model.java.util.Vector getFilteredElements()
getFilterExpression()
. If no
filter is set, all elements will be returned. If the datasource content
is changed, on the next call of this method the filter is applied first
before returning the result.getFilterExpression()
or all
elements if getFilterExpression()
returns
null
boolean isFilteredElement(java.lang.Object object)
true
if the given object matches the filter for this
datasource returned by getFilterExpression()
. You need to
implement this method specifically for your datasource and the object
types managed.object
- the object to test if it matches
getFilterExpression()
true
if the filter returned by
getFilterExpression()
matches the object,
false
if it does notjava.lang.Object getElementAtIndex(int index)
index
- the row index of the object starting at 0.void setElements(java.util.Vector objects)
Vector
of objects. This overwrites the current elements.the
- objects to be managed by the datasourcevoid setFilterExpression(java.lang.String filter)
getNumberOfElements()
,
getElements()
, etc. You typically use filter to implement
searches in a . An expression can be any String an
IListDatasource
implementation uses to reference an object.filter
- the filter string the datasource uses to filter it's contentjava.lang.String getFilterExpression()
null
will be returnedvoid removeElementAtIndex(int index)
index
- the row index of the object to be removedvoid removeElement(java.lang.Object object)
object
- the object to be removedvoid removeAllElements()
void addElement(java.lang.Object object)
object
- the object to be added to the data modelvoid addElementAtIndex(java.lang.Object object, int index)
object
- the object to be added to the data modelindex
- the index to add the object atvoid addElements(java.util.Vector objects)
objects
- a Vector
of objects to be addedvoid setSelectedElement(java.lang.Object object)
ListView
.object
- the selected objectjava.lang.Object getSelectedElement()
ListView
or
null
if no object was set as selected.ListView
void setComparator(IComparator comparator)
IComparator
implementation to be used
when sorting or resort
ing the data model represention in the
ListView
.comparator
- the comparator implementation used for sortingIComparator getComparator()
IComparator
used by the
ListView
.IComparator
implementation currently used or
null
if sorting is disabled.void resort()
ListView.reload()
to reflect the changes in the user interface.boolean hasException()
true
if there was an exception when initializing the
elements.DatasourceException getException()