public abstract class Filter extends AbstractDataSource implements DataListener
Abstract class that provides basic functions for filtering arbitrary columns of a DataSource, in other words a set of one-dimensional data.
Functionality includes:
Filter.Mode
)Values of filtered columns are buffered. Access to unfiltered columns is
delegated to the original data source. Derived classes must make sure the
caches are updated when deserialization is done. This can be done by calling
dataUpdated(this)
in a custom deserialization method.
Modifier and Type | Class and Description |
---|---|
static class |
Filter.Mode
Type to define the behavior when engaging the borders of a column, i.e.
|
Constructor and Description |
---|
Filter(DataSource original,
Filter.Mode mode,
int... cols)
Initializes a new instance with the specified data source, border
handling and columns to be filtered.
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(Double[] rowData)
Adds the specified row data to this Filter.
|
protected void |
add(Number[] rowData)
Adds the specified row data to this Filter.
|
protected void |
clear()
Clears this Filter.
|
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.
|
protected abstract void |
filter()
Invokes the filtering routine.
|
Comparable<?> |
get(int col,
int row)
Returns the row with the specified index.
|
int |
getColumnCount()
Returns the number of columns of the data source.
|
protected int |
getColumnCountFiltered()
Returns the number of filtered columns.
|
protected int |
getIndex(int col)
Returns the index of the filtered column using the index of the
original column.
|
protected int |
getIndexOriginal(int col)
Returns the index of the original column using the index of the
filtered column.
|
Filter.Mode |
getMode()
Returns the Mode of this Filter.
|
protected DataSource |
getOriginal()
Returns the original data source that is filtered.
|
protected Comparable<?> |
getOriginal(int col,
int row)
Returns the value of the original data source at the specified column
and row.
|
int |
getRowCount()
Returns the number of rows of the data source.
|
protected int |
getRowCountFiltered()
Returns the number of filtered rows.
|
protected boolean |
isFiltered(int col)
Returns whether the specified column is filtered.
|
protected Number |
set(int col,
int row,
Double value)
Sets a new value for a specified cell.
|
void |
setMode(Filter.Mode mode)
Sets the Mode the specified value.
|
addDataListener, getColumn, getColumnTypes, getRow, getStatistics, isColumnNumeric, iterator, notifyDataAdded, notifyDataRemoved, notifyDataUpdated, removeDataListener, setColumnTypes
public Filter(DataSource original, Filter.Mode mode, int... cols)
IllegalArgumentException
is thrown.original
- Data source to be filtered.mode
- Border handling mode to be used.cols
- Indexes of numeric columns to be filtered.protected DataSource getOriginal()
protected Comparable<?> getOriginal(int col, int row)
col
- Column index.row
- Row index.protected void clear()
protected void add(Double[] rowData)
rowData
- Row data to be added.protected void add(Number[] rowData)
rowData
- Row to be added.public Comparable<?> get(int col, int row)
get
in interface DataSource
col
- index of the column to returnrow
- index of the row to returnprotected Number set(int col, int row, Double value)
col
- Column of the cell.row
- Row of the cell.value
- New cell value.public int getColumnCount()
AbstractDataSource
getColumnCount
in interface DataSource
getColumnCount
in class AbstractDataSource
protected int getColumnCountFiltered()
public int getRowCount()
getRowCount
in interface DataSource
protected int getRowCountFiltered()
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 changedevents
- Optional event object describing the data values that
have been updated.public void dataRemoved(DataSource source, DataChangeEvent... events)
DataListener
s and should not be called manually.dataRemoved
in interface DataListener
source
- Data source that has been changedevents
- Optional event object describing the data values that
have been removed.protected int getIndexOriginal(int col)
col
- Index of the filtered columnprotected int getIndex(int col)
col
- Index of the original columnprotected boolean isFiltered(int col)
col
- Column index.protected abstract void filter()
public Filter.Mode getMode()
public void setMode(Filter.Mode mode)
mode
- Mode of filtering.Copyright © 2009-2013. All Rights Reserved.