Documentation of 'de.erichseifert.gral.data.RowSubset' Java class
RowSubset
de.erichseifert.gral.data

Class 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 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: AbstractDataSource
        Returns the row with the specified index.
        Specified by:
        getRow in interface DataSource
        Overrides:
        getRow in class AbstractDataSource
        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:
        get in interface DataSource
        Parameters:
        col - index of the column to return
        row - index of the row to return
        Returns:
        the specified value of the data cell
      • getRowCount

        public int getRowCount()
        Returns the number of rows of the data source.
        Specified by:
        getRowCount in interface DataSource
        Returns:
        number of rows 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 for DataListeners and should not be called manually.
        Specified by:
        dataAdded in interface DataListener
        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 for DataListeners and should not be called manually.
        Specified by:
        dataUpdated in interface DataListener
        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 for DataListeners and should not be called manually.
        Specified by:
        dataRemoved in interface DataListener
        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

Ads help maintain this website.