public abstract class AbstractListDatasource extends Observable implements IListDatasource
IListDatasource
based on a
Vector
to manage its data model. It uses Observable
to notify
changes to a number of Observer
.Constructor and Description |
---|
AbstractListDatasource() |
AbstractListDatasource(Observer observer) |
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.
|
int |
compare(java.lang.Object o1,
java.lang.Object o2) |
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.
|
abstract java.lang.Object |
getExpressionValue(java.lang.String rootExpression)
This method is used to retrieve an object from the data model using an
expression.
|
abstract java.lang.Object |
getExpressionValue(java.lang.String relativeExpression,
int elementIndex)
This method is used to get the object from 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
IListDatasource.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 IListDatasource.getFilterExpression() . |
abstract 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 resorting 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. |
abstract void |
setExpressionValue(java.lang.String rootExpression,
java.lang.Object value)
This method is used to update an object in the data model.
|
abstract void |
setExpressionValue(java.lang.String relativeExpression,
java.lang.Object value,
int elementIndex)
This method is used to set the object in the data model using an
expression that is relative to on object in the data model with the given
row index.
|
void |
setFilterExpression(java.lang.String valueFilter)
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 . |
addObserver, deleteObserver, notifyObservers, notifyObservers
public AbstractListDatasource()
public AbstractListDatasource(Observer observer)
public java.lang.String getFilterExpression()
IListDatasource
null
will be returnedgetFilterExpression
in interface IListDatasource
public void setFilterExpression(java.lang.String valueFilter)
IListDatasource
IListDatasource.getNumberOfElements()
,
IListDatasource.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.setFilterExpression
in interface IListDatasource
valueFilter
- the filter string the datasource uses to filter it's contentpublic java.util.Vector getFilteredElements()
IListDatasource
IListDatasource.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.getFilteredElements
in interface IListDatasource
IListDatasource.getFilterExpression()
or all
elements if IListDatasource.getFilterExpression()
returns
null
public boolean isFilteredElement(java.lang.Object object)
IListDatasource
true
if the given object matches the filter for this
datasource returned by IListDatasource.getFilterExpression()
. You need to
implement this method specifically for your datasource and the object
types managed.isFilteredElement
in interface IListDatasource
object
- the object to test if it matches
IListDatasource.getFilterExpression()
true
if the filter returned by
IListDatasource.getFilterExpression()
matches the object,
false
if it does notpublic java.util.Vector getElements()
IListDatasource
Vector
returned will not change the
contents of the data model.getElements
in interface IListDatasource
public int getNumberOfElements()
IListDatasource
getNumberOfElements
in interface IListDatasource
public abstract java.lang.Object getExpressionValue(java.lang.String rootExpression) throws java.lang.Exception
IDatasource
IDatasource
implementation uses to reference an object.getExpressionValue
in interface IDatasource
rootExpression
- String that references an object in the data modelnull
if there
was no objectjava.lang.Exception
- if an error occured evaluating the given expressionpublic abstract java.lang.Object getExpressionValue(java.lang.String relativeExpression, int elementIndex) throws java.lang.Exception
IListDatasource
IDatasource
implementation uses to reference an object.getExpressionValue
in interface IListDatasource
elementIndex
- 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 expressionpublic abstract void setExpressionValue(java.lang.String rootExpression, java.lang.Object value) throws java.lang.Exception
IDatasource
IDatasource
implementation uses to reference an object.setExpressionValue
in interface IDatasource
rootExpression
- String that references an object in the data modelvalue
- new object value for the given expressionjava.lang.Exception
- if an error occured evaluating the given expressionpublic abstract void setExpressionValue(java.lang.String relativeExpression, java.lang.Object value, int elementIndex) throws java.lang.Exception
IListDatasource
IDatasource
implementation uses to reference an object.setExpressionValue
in interface IListDatasource
relativeExpression
- String that references an object in the data modelvalue
- the new value for the given expressionelementIndex
- the index of the object to be used to evaluate the given
expressionjava.lang.Exception
- if an error occured evaluating the given expressionpublic void removeElementAtIndex(int index)
IListDatasource
removeElementAtIndex
in interface IListDatasource
index
- the row index of the object to be removedpublic void removeElement(java.lang.Object object)
IListDatasource
removeElement
in interface IListDatasource
object
- the object to be removedpublic void removeAllElements()
IListDatasource
removeAllElements
in interface IListDatasource
public void addElement(java.lang.Object object)
IListDatasource
addElement
in interface IListDatasource
object
- the object to be added to the data modelpublic void addElementAtIndex(java.lang.Object object, int index)
IListDatasource
addElementAtIndex
in interface IListDatasource
object
- the object to be added to the data modelindex
- the index to add the object atpublic void addElements(java.util.Vector objects)
IListDatasource
addElements
in interface IListDatasource
objects
- a Vector
of objects to be addedpublic void setElements(java.util.Vector objects)
IListDatasource
Vector
of objects. This overwrites the current elements.setElements
in interface IListDatasource
objects
- to be managed by the datasourcepublic java.lang.Object getElementAtIndex(int index)
IListDatasource
getElementAtIndex
in interface IListDatasource
index
- the row index of the object starting at 0.public void setSelectedElement(java.lang.Object object)
IListDatasource
ListView
.setSelectedElement
in interface IListDatasource
object
- the selected objectpublic java.lang.Object getSelectedElement()
IListDatasource
ListView
or
null
if no object was set as selected.getSelectedElement
in interface IListDatasource
ListView
public void setComparator(IComparator comparator)
IListDatasource
IComparator
implementation to be used
when sorting or resorting the data model represention in the
ListView
.setComparator
in interface IListDatasource
comparator
- the comparator implementation used for sortingpublic IComparator getComparator()
IListDatasource
IComparator
used by the
ListView
.getComparator
in interface IListDatasource
IComparator
implementation currently used or
null
if sorting is disabled.public int compare(java.lang.Object o1, java.lang.Object o2)
public void resort()
IListDatasource
ListView.reload()
to reflect the changes in the user interface.resort
in interface IListDatasource
public boolean hasException()
IListDatasource
hasException
in interface IListDatasource
true
if there was an exception when initializing the
elements.public DatasourceException getException()
IListDatasource
getException
in interface IListDatasource
public abstract void reloadElements()
IListDatasource
reloadElements
in interface IListDatasource