org.knime.base.data.filter.column
Class FilterColumnTable

java.lang.Object
  extended by org.knime.base.data.filter.column.FilterColumnTable
All Implemented Interfaces:
Iterable<DataRow>, DataTable

public final class FilterColumnTable
extends Object
implements DataTable

This DataTable filters (includes or excludes) a specified number of columns from a given table by just wrapping the underlying data table.

These columns can be either filtered by a particular column DataType, by a list of column names, or indices whereby the ordering is maintained. Note, it is not possible to select a column twice from the given table.

The ordering of the final table is depending on the order of the column names resp. column indices.

Author:
Thomas Gabriel, University of Konstanz

Constructor Summary
FilterColumnTable(DataTable data, boolean include, int... columns)
          Inits a new filter column table based on a DataTable and an unique, unordered number of column indices.
FilterColumnTable(DataTable data, Class<? extends DataValue> value)
          Inits a new filter column table based on a DataTable and a DataValue class as value.
FilterColumnTable(DataTable data, DataType type)
          Inits a new filter column table based on a DataTable and one type (DataCell)) using Class to extract these columns.
FilterColumnTable(DataTable data, int... columns)
          Inits a new filter column table based on a DataTable and an unique, unordered number of column indices.
FilterColumnTable(DataTable data, String... columns)
          Inits a new filter column table based on a DataTable and a unique, unordered number of column names.
 
Method Summary
static DataTableSpec createFilterTableSpec(DataTableSpec spec, boolean include, int... columns)
          This function constructs a spec for this filter table.
static DataTableSpec createFilterTableSpec(DataTableSpec spec, int... columns)
          This function constructs a spec for this filter table.
static DataTableSpec createFilterTableSpec(DataTableSpec spec, String... columns)
          Calls createFilterTableSpec(DataTableSpec, int[]) arguments with the correct values in the int[] argument, i.e.
 int[] getColumnIndices()
           
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 RowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterColumnTable

public FilterColumnTable(DataTable data,
                         boolean include,
                         int... columns)
Inits a new filter column table based on a DataTable and an unique, unordered number of column indices.

Parameters:
data - the underlying data table
columns - the column indices to INCLUDE or EXCLUDE from the table
include - if true the columns are INCLUDEd otherwise EXCLUDEd
Throws:
ArrayIndexOutOfBoundsException - if one of the column indices lies not within the table's column range
IllegalArgumentException - if the data or columns are null, or column indices are out of range or appear as duplicates in the array

FilterColumnTable

public FilterColumnTable(DataTable data,
                         int... columns)
Inits a new filter column table based on a DataTable and an unique, unordered number of column indices.

Parameters:
data - the underlying data table
columns - the column indices to INCLUDE in the new table
Throws:
NullPointerException - if one of the args is null
ArrayIndexOutOfBoundsException - if one of the column indices lies not within the table's column range
IllegalArgumentException - if the column indices are empty or one of the column indices is used twice

FilterColumnTable

public FilterColumnTable(DataTable data,
                         String... columns)
Inits a new filter column table based on a DataTable and a unique, unordered number of column names.

Parameters:
data - the underlying data table
columns - the column name to filter
Throws:
NullPointerException - if one of the args is null
IllegalArgumentException - if one of the column name is already is use or the column name does not exist in the table.

FilterColumnTable

public FilterColumnTable(DataTable data,
                         DataType type)
Inits a new filter column table based on a DataTable and one type (DataCell)) using Class to extract these columns.

Parameters:
data - the underlying table
type - the column type to be extractedt
Throws:
IllegalArgumentException - if the given type does not appear in the table

FilterColumnTable

public FilterColumnTable(DataTable data,
                         Class<? extends DataValue> value)
Inits a new filter column table based on a DataTable and a DataValue class as value. This table will contain all columns from data which are compatible to value.

Parameters:
data - the underlying table
value - the compatible value type to be included
Throws:
NullPointerException - if any argument is null
Method Detail

createFilterTableSpec

public static final DataTableSpec createFilterTableSpec(DataTableSpec spec,
                                                        String... columns)
Calls createFilterTableSpec(DataTableSpec, int[]) arguments with the correct values in the int[] argument, i.e. it will locate the columns and assign the "right" values.

Parameters:
spec - the input spec
columns - the names of the columns that should survive
Returns:
a new spec with extracted columns
Throws:
IndexOutOfBoundsException - if columns are no available
NullPointerException - if either argument is null or contains null values

createFilterTableSpec

public static final DataTableSpec createFilterTableSpec(DataTableSpec spec,
                                                        boolean include,
                                                        int... columns)
This function constructs a spec for this filter table. From the given table spec it extracts the specified indicies and arranges them accordingly. It stores references in the new table spec pointing to objects referenced to by the passed table spec.

Parameters:
spec - the input spec
include - whether the column indices are to include or exclude
columns - the output column indices to extract from the input spec
Returns:
a new spec with extracted columns
Throws:
IndexOutOfBoundsException - if columns not available
NullPointerException - if either argument is null or contains null values

createFilterTableSpec

public static final DataTableSpec createFilterTableSpec(DataTableSpec spec,
                                                        int... columns)
This function constructs a spec for this filter table. From the given table spec it extracts the specified indicies and arranges them accordingly. It stores references in the new table spec pointing to objects referenced to by the passed table spec.

Parameters:
spec - the input spec
columns - The output column indices to extract from the input spect
Returns:
a new spec with extracted columns
Throws:
IndexOutOfBoundsException - if columns are not availablea
NullPointerException - if either argument is null or contains null values

getColumnIndices

public int[] getColumnIndices()
Returns:
a copy of the used column indices from the filtered data table

getDataTableSpec

public DataTableSpec getDataTableSpec()
Returns the DataTableSpec object of this table which gives information about the structure of this data table.

Specified by:
getDataTableSpec in interface DataTable
Returns:
the DataTableSpec of this table

iterator

public RowIterator iterator()
Returns a row iterator which returns each row one-by-one from the table.

Specified by:
iterator in interface Iterable<DataRow>
Specified by:
iterator in interface DataTable
Returns:
row iterator
See Also:
DataRow


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.