org.knime.core.data
Class DataColumnSpecCreator

java.lang.Object
  extended by org.knime.core.data.DataColumnSpecCreator

public final class DataColumnSpecCreator
extends Object

A factory class to create a DataColumnSpec (as the only way from outside this package). It can be created from an existing spec or by specifying a column name and DataType. Setter functions allow to overwrite all available members within the creator but the (later) created DataColumnSpec will be read-only after creation.

In addition, a ColorHandler, SizeHandler, and/or ShapeHandler can be set optionally to specify color, shape, and size. An DataColumnProperties object can be used to specify annotations as key-value pairs.

Author:
Michael Berthold, University of Konstanz
See Also:
DataColumnSpec, createSpec()

Constructor Summary
DataColumnSpecCreator(DataColumnSpec cspec)
          Initializes the creator with a given DataColumnSpec.
DataColumnSpecCreator(String name, DataType type)
          Initializes the creator with the given column name and type.
 
Method Summary
 DataColumnSpec createSpec()
          Creates and returns a new DataColumnSpec using the internal properties of this creator.
 void merge(DataColumnSpec cspec2)
          Merges the existing DataColumnSpec with a second DataColumnSpec.
 void removeAllHandlers()
          Removes all handlers from this creator which are then set to null for the next call of #createSpec().
 void setColorHandler(ColorHandler colorHdl)
          Set (new) ColorHandler which can be null.
 void setDomain(DataColumnDomain domain)
          Set (new) domain.
 void setElementNames(String[] elNames)
          Set names of elements when this column contains a vector type.
 void setName(String name)
          Set (new) column name.
 void setProperties(DataColumnProperties props)
          Set (new) column properties.
 void setShapeHandler(ShapeHandler shapeHdl)
          Set (new) ShapeHandler which can be null.
 void setSizeHandler(SizeHandler sizeHdl)
          Set (new) SizeHandler which can be null.
 void setType(DataType type)
          Set (new) column type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataColumnSpecCreator

public DataColumnSpecCreator(String name,
                             DataType type)
Initializes the creator with the given column name and type. The DataColumnProperties are left empty and color, size, and shape handler are set to null.

Parameters:
name - the column name
type - the column type
Throws:
NullPointerException - if either the column name or type is null

DataColumnSpecCreator

public DataColumnSpecCreator(DataColumnSpec cspec)
Initializes the creator with a given DataColumnSpec.

Parameters:
cspec - other spec
Method Detail

merge

public void merge(DataColumnSpec cspec2)
Merges the existing DataColumnSpec with a second DataColumnSpec. If they have equal structure, the domain information and properties from both DataColumnSpecs is merged, Color, Shape and Size-Handlers are compared (must be equal).

Parameters:
cspec2 - the second DataColumnSpec.
Throws:
IllegalArgumentException - if the structure (type and name) does not match, if the domain can not be merged, if the Color-, Shape- or SizeHandlers are different or the sub element names are not equal.
See Also:
DataTableSpec.mergeDataTableSpecs(DataTableSpec...)

setName

public void setName(String name)
Set (new) column name. If the column name is empty or consists only of whitespaces, a warning is logged and an artificial name is created.

Parameters:
name - the (new) column name
Throws:
NullPointerException - if the column name is null

setElementNames

public void setElementNames(String[] elNames)
Set names of elements when this column contains a vector type. By default (i.e. non-vector types) the array has length 1 and contains the name of the column. If the argument is null, a default name array will be used when the final DataColumnSpec is created (the array will contain the then-actual name of the column).

Parameters:
elNames - The elements names/identifiers to set.
Throws:
NullPointerException - If the argument contains null elements.
See Also:
DataColumnSpec.getElementNames()

setType

public void setType(DataType type)
Set (new) column type.

Parameters:
type - the (new) column type
Throws:
NullPointerException - if the column type is null

setDomain

public void setDomain(DataColumnDomain domain)
Set (new) domain. If a null domain is set, an empty domain will be created.

Parameters:
domain - the (new) domain, if null an empty default domain will be created

setProperties

public void setProperties(DataColumnProperties props)
Set (new) column properties. If a null properties object is passed, a new empty property object will be created.

Parameters:
props - the (new) properties, if null an empty props object is created

setSizeHandler

public void setSizeHandler(SizeHandler sizeHdl)
Set (new) SizeHandler which can be null.

Parameters:
sizeHdl - the (new) SizeHandler or null

setShapeHandler

public void setShapeHandler(ShapeHandler shapeHdl)
Set (new) ShapeHandler which can be null.

Parameters:
shapeHdl - the (new) ShapeHandler or null

setColorHandler

public void setColorHandler(ColorHandler colorHdl)
Set (new) ColorHandler which can be null.

Parameters:
colorHdl - the (new) ColorHandler or null

removeAllHandlers

public void removeAllHandlers()
Removes all handlers from this creator which are then set to null for the next call of #createSpec().


createSpec

public DataColumnSpec createSpec()
Creates and returns a new DataColumnSpec using the internal properties of this creator.

Returns:
newly created DataColumnSpec


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.