public abstract class RowSubset extends AbstractDataSource implements DataListener
Abstract class that represents a view on several rows of a data source.
Implementations must implement the method accept(Row)
which
decides whether a specific row should be contained in this filtered data
source.
Example that keeps only every second row:
DataSource filtered = new RowSubset() { public boolean accept(Row row) { return row.getIndex()%2 == 0; } };
Constructor and Description |
---|
RowSubset(DataSource original)
Creates a new instance with the specified data source.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
accept(Row row)
Tests whether the specified row is accepted by this DataSubset or not.
|
void |
dataAdded(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been added.
|
void |
dataRemoved(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been removed.
|
void |
dataUpdated(DataSource source,
DataChangeEvent... events)
Method that is invoked when data has been updated.
|
Comparable<?> |
get(int col,
int row)
Returns the row with the specified index.
|
int |
getColumnCount()
Returns the number of columns of the data source.
|
Class<? extends Comparable<?>>[] |
getColumnTypes()
Returns the data types of all columns.
|
Row |
getRow(int row)
Returns the row with the specified index.
|
int |
getRowCount()
Returns the number of rows of the data source.
|
addDataListener, getColumn, getStatistics, isColumnNumeric, iterator, notifyDataAdded, notifyDataRemoved, notifyDataUpdated, removeDataListener, setColumnTypes
public RowSubset(DataSource original)
original
- DataSource to be filtered.public Row getRow(int row)
AbstractDataSource
getRow
in interface DataSource
getRow
in class AbstractDataSource
row
- Index of the row to returnpublic Comparable<?> get(int col, int row)
get
in interface DataSource
col
- index of the column to returnrow
- index of the row to returnpublic int getColumnCount()
AbstractDataSource
getColumnCount
in interface DataSource
getColumnCount
in class AbstractDataSource
public int getRowCount()
getRowCount
in interface DataSource
public Class<? extends Comparable<?>>[] getColumnTypes()
AbstractDataSource
getColumnTypes
in interface DataSource
getColumnTypes
in class AbstractDataSource
public void dataAdded(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataAdded
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been added.public void dataUpdated(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataUpdated
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been addedpublic void dataRemoved(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataRemoved
in interface DataListener
source
- Data source that has been changed.events
- Optional event object describing the data values that
have been removed.public abstract boolean accept(Row row)
row
- Row to be tested.Copyright © 2009-2013. All Rights Reserved.