org.knime.core.data.collection
Class CollectionCellFactory

java.lang.Object
  extended by org.knime.core.data.collection.CollectionCellFactory

public final class CollectionCellFactory
extends Object

Factory class used to create DataCells that contain a collection of DataCells. Also provides convenient methods to determine the type of the elements (the common super type), if no such collection cell is at hand.

Author:
ohl, University of Konstanz

Method Summary
static ListCell createListCell(Collection<? extends DataCell> coll)
          Factory method to create a ListCell based on a collection.
static ListCell createListCell(DataRow row, int[] cols)
          Creates a new ListCell based on selected cells from a DataRow.
static SetCell createSetCell(Collection<? extends DataCell> coll)
          Factory method to create a SetCell that contains a data cell set based on a collection.
static SetCell createSetCell(DataRow row, int[] cols)
          Create new SetCell containing a set based on selected cell from a DataRow.
static DataType getElementType(DataTableSpec tableSpec, int[] cols)
          Determines the super type of the specified columns.
static DataType getElementType(DataType[] colType)
          Determines the super type of all types passed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createListCell

public static ListCell createListCell(Collection<? extends DataCell> coll)
Factory method to create a ListCell based on a collection.

If the underlying collection stems from a DataRow (as read from a any table), consider to use createListCell(DataRow, int[]) in order to minimize cell access.

Parameters:
coll - The underlying collection.
Returns:
The newly created ListCell.
Throws:
NullPointerException - If the argument is null or contains null values.

createListCell

public static ListCell createListCell(DataRow row,
                                      int[] cols)
Creates a new ListCell based on selected cells from a DataRow. Using this method will check if the row is returned by a BufferedDataTable and will handle blobs appropriately.

Parameters:
row - The underlying row
cols - The indices of interest.
Returns:
A newly created ListCell.
Throws:
NullPointerException - If either argument is null.
IndexOutOfBoundsException - If the indices are invalid.

createSetCell

public static SetCell createSetCell(Collection<? extends DataCell> coll)
Factory method to create a SetCell that contains a data cell set based on a collection.

If the underlying collection stems from a DataRow (as read from a any table), consider to use createSetCell(DataRow, int[]) in order to minimize cell access.

Parameters:
coll - The underlying collection.
Returns:
The newly created SetCell.
Throws:
NullPointerException - If the argument is null or contains null values.

createSetCell

public static SetCell createSetCell(DataRow row,
                                    int[] cols)
Create new SetCell containing a set based on selected cell from a DataRow. Using this method will check if the row is returned by a BufferedDataTable and will handle blobs appropriately.

Parameters:
row - The underlying row
cols - The indices of cells to be stored in the set.
Returns:
A newly created SetCell.
Throws:
NullPointerException - If either argument is null.
IndexOutOfBoundsException - If the indices are invalid.

getElementType

public static DataType getElementType(DataTableSpec tableSpec,
                                      int[] cols)
Determines the super type of the specified columns. This type will be the element type if a collection is created from the elements in the specified columns.

Parameters:
tableSpec - containing the types of the selected columns
cols - the indices of the columns to determine the common super type of
Returns:
the common super type of the specified columns in the table spec
Throws:
NullPointerException - if either of the arguments is null
ArrayIndexOutOfBoundsException - if the provided column indices are invalid.

getElementType

public static DataType getElementType(DataType[] colType)
Determines the super type of all types passed. This type will be the element type if a collection is created from element of this type.

Parameters:
colType - the types of which the common super type should be returned.
Returns:
the common super type of the specified types
Throws:
NullPointerException - if the array or one of its elements is null


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.