de.erichseifert.gral.data
Class RowSubset
- java.lang.Object
-
- de.erichseifert.gral.data.AbstractDataSource
-
- de.erichseifert.gral.data.RowSubset
-
- All Implemented Interfaces:
- DataListener, DataSource, java.io.Serializable, java.lang.Iterable<java.lang.Comparable<?>>
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; } };- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RowSubset(DataSource original)Creates a new instance with the specified data source.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract booleanaccept(Row row)Tests whether the specified row is accepted by this DataSubset or not.voiddataAdded(DataSource source, DataChangeEvent... events)Method that is invoked when data has been added.voiddataRemoved(DataSource source, DataChangeEvent... events)Method that is invoked when data has been removed.voiddataUpdated(DataSource source, DataChangeEvent... events)Method that is invoked when data has been updated.java.lang.Comparable<?>get(int col, int row)Returns the row with the specified index.intgetColumnCount()Returns the number of columns of the data source.java.lang.Class<? extends java.lang.Comparable<?>>[]getColumnTypes()Returns the data types of all columns.RowgetRow(int row)Returns the row with the specified index.intgetRowCount()Returns the number of rows of the data source.-
Methods inherited from class de.erichseifert.gral.data.AbstractDataSource
addDataListener, getColumn, getColumnStatistics, getName, getRecord, getRowStatistics, getStatistics, isColumnNumeric, iterator, removeDataListener
-
-
-
-
Constructor Detail
-
RowSubset
public RowSubset(DataSource original)
Creates a new instance with the specified data source.- Parameters:
original- DataSource to be filtered.
-
-
Method Detail
-
getRow
public Row getRow(int row)
Description copied from class:AbstractDataSourceReturns the row with the specified index.- Specified by:
getRowin interfaceDataSource- Overrides:
getRowin classAbstractDataSource- Parameters:
row- Index of the row to return- Returns:
- the Specified row of the data source
-
get
public java.lang.Comparable<?> get(int col, int row)Returns the row with the specified index.- Specified by:
getin interfaceDataSource- Parameters:
col- index of the column to returnrow- index of the row to return- Returns:
- the specified value of the data cell
-
getColumnCount
public int getColumnCount()
Description copied from class:AbstractDataSourceReturns the number of columns of the data source.- Specified by:
getColumnCountin interfaceDataSource- Overrides:
getColumnCountin classAbstractDataSource- Returns:
- number of columns in the data source.
-
getRowCount
public int getRowCount()
Returns the number of rows of the data source.- Specified by:
getRowCountin interfaceDataSource- Returns:
- number of rows in the data source.
-
getColumnTypes
public java.lang.Class<? extends java.lang.Comparable<?>>[] getColumnTypes()
Description copied from class:AbstractDataSourceReturns the data types of all columns.- Specified by:
getColumnTypesin interfaceDataSource- Overrides:
getColumnTypesin classAbstractDataSource- Returns:
- The data types of all column in the data source
-
dataAdded
public void dataAdded(DataSource source, DataChangeEvent... events)
Method that is invoked when data has been added. This method is invoked by objects that provide support forDataListeners and should not be called manually.- Specified by:
dataAddedin interfaceDataListener- Parameters:
source- Data source that has been changed.events- Optional event object describing the data values that have been added.
-
dataUpdated
public void dataUpdated(DataSource source, DataChangeEvent... events)
Method that is invoked when data has been updated. This method is invoked by objects that provide support forDataListeners and should not be called manually.- Specified by:
dataUpdatedin interfaceDataListener- Parameters:
source- Data source that has been changed.events- Optional event object describing the data values that have been added
-
dataRemoved
public void dataRemoved(DataSource source, DataChangeEvent... events)
Method that is invoked when data has been removed. This method is invoked by objects that provide support forDataListeners and should not be called manually.- Specified by:
dataRemovedin interfaceDataListener- Parameters:
source- Data source that has been changed.events- Optional event object describing the data values that have been removed.
-
accept
public abstract boolean accept(Row row)
Tests whether the specified row is accepted by this DataSubset or not.- Parameters:
row- Row to be tested.- Returns:
- True if the row should be kept.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG