org.knime.core.data.util
Class ObjectToDataCellConverter

java.lang.Object
  extended by org.knime.core.data.util.ObjectToDataCellConverter

Deprecated. This class is obsolete as the class DefaultTable is deprecated. DataCell objects should be created using their respective constructor rather than using an ObjectToDataCellConverter.

public class ObjectToDataCellConverter
extends Object

Factory to get DataCell representation for various (java-)objects.

This class is used within the DefaultTable to wrap java objects in DataCell. If you implement your own DataCell and use the DefaultTable, you probably want to override this class.

This default implementation serves to get DataCell instances for basic java objects like String, Integer, Double and their generic types like int, byte, double etc.

To implement additional functionality, you usually override the proper createDataCell method like this:

 ObjectToDataCellConverter converter = new ObjectToDataCellConverter() {
     public DataCell createDataCell(final Object o) {
         if (o instanceof FooObject) {
             return new FooDataCell((FooObject)o);
         }
         if (o instanceof FooBarObject) {
             return new FooBarDataCell((FooBarObject)o);
         }
         return super.createDataCell(o);
     }
 };
 
It is also up to the user to implement further handling in the factory method for generic data types.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
DefaultTable.DefaultTable( Object[][], String[], String[], ObjectToDataCellConverter)

Field Summary
static ObjectToDataCellConverter INSTANCE
          Deprecated. Singleton to be used for default handling.
 
Constructor Summary
ObjectToDataCellConverter()
          Deprecated.  
 
Method Summary
 DataCell createDataCell(boolean b)
          Deprecated. Creates new IntCell for a boolean having value 1 if b==true or 0 if b==false.
 DataCell createDataCell(byte b)
          Deprecated. Creates new IntCell for a byte.
 DataCell createDataCell(double d)
          Deprecated. Creates new DoubleCell for a double.
 DataCell createDataCell(float f)
          Deprecated. Creates new DoubleCell for a float.
 DataCell createDataCell(int i)
          Deprecated. Creates new IntCell for an int.
 DataCell createDataCell(Object o)
          Deprecated. Factory method to get DataCells from basic types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final ObjectToDataCellConverter INSTANCE
Deprecated. 
Singleton to be used for default handling. This convenience object may be used when default handling is sufficient.

Constructor Detail

ObjectToDataCellConverter

public ObjectToDataCellConverter()
Deprecated. 
Method Detail

createDataCell

public DataCell createDataCell(Object o)
Deprecated. 
Factory method to get DataCells from basic types. This implementation creates DataCells depending on the class type of o as follows:
Class or value of o Return class
null StringCell.INSTANCE
String StringCell
Integer IntCell
Byte IntCell
Double DoubleCell
Float DoubleCell

Parameters:
o - The object to be converted into a DataCell or null to indicate a missing value.
Returns:
a new DataCell representing o.
Throws:
IllegalArgumentException - if o is not an instance of the classes mentioned above. Derivates may override this behavior.

createDataCell

public DataCell createDataCell(double d)
Deprecated. 
Creates new DoubleCell for a double.

Parameters:
d - Double to be wrapped in a DataCell
Returns:
new DoubleCell(d);
See Also:
DoubleCell

createDataCell

public DataCell createDataCell(float f)
Deprecated. 
Creates new DoubleCell for a float.

Parameters:
f - Float to be wrapped in a DataCell
Returns:
new DoubleCell((double)f);
See Also:
DoubleCell

createDataCell

public DataCell createDataCell(int i)
Deprecated. 
Creates new IntCell for an int.

Parameters:
i - Int to be wrapped in a DataCell
Returns:
new IntCell(i);
See Also:
IntCell

createDataCell

public DataCell createDataCell(byte b)
Deprecated. 
Creates new IntCell for a byte.

Parameters:
b - Byte to be wrapped in a DataCell
Returns:
new IntCell((int)b);
See Also:
IntCell

createDataCell

public DataCell createDataCell(boolean b)
Deprecated. 
Creates new IntCell for a boolean having value 1 if b==true or 0 if b==false.

Parameters:
b - Boolean to be wrapped in a DataCell
Returns:
A new IntCell having either value 1 or 0 depending on b
See Also:
IntCell


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.