org.knime.core.data
Class DataCell

java.lang.Object
  extended by org.knime.core.data.DataCell
All Implemented Interfaces:
Serializable, DataValue
Direct Known Subclasses:
BitVectorCell, BlobDataCell, BlobWrapperDataCell, ComplexNumberCell, DateAndTimeCell, DenseBitVectorCell, DenseByteVectorCell, DoubleCell, FuzzyIntervalCell, FuzzyNumberCell, IntCell, IntervalCell, ListCell, LongCell, SetCell, SparseBitVectorCell, SparseByteVectorCell, StringCell, TimestampCell

public abstract class DataCell
extends Object
implements DataValue, Serializable

Abstract base class of all DataCells, which acts as a container for arbitrary values and defines the common abilities all cells must provide, that is: retrieve the cell type, a string representation of the value, find out if this cell is missing, and test whether it is equal to another one.

Derived classes have to implement at least one interface derived from DataValue. The derived class must be read-only, i.e. setter methods must not be implemented.

This class implements Serializable. However, if you define a custom DataCell implementation, consider to implement a factory that takes care of reading and writing a cell to a DataInput or DataOutput source. Ordinary Java serialization is considerably slower than implementing your own DataCellSerializer. To register such a serializer, define a static method having the following signature:

   public static final DataCellSerializer<YourCellClass> 
       getCellSerializer() {
     ...
   }
 
where YourCellClass is the name of your DataCell implementation. This method will be called by reflection, whenever the cell at hand needs to be written or read.

Since DataCell may implement different DataValue interfaces but only one is the preferred value class, implement a static method in your derived class with the following signature:

    public static final Class<? extends DataValue> 
      getPreferredValueClass() {
        ...
    }
 
This method is called once when the runtime DataType of the cell is created using reflection. The associated DataType provides the renderer, icon, and comparator of this preferred value. If this method is not implemented, the order on the value interfaces is undefined.

For further details on data types, see also the package description and the manual on defining new cell types.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
DataType, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.knime.core.data.DataValue
DataValue.UtilityFactory
 
Field Summary
 
Fields inherited from interface org.knime.core.data.DataValue
UTILITY
 
Constructor Summary
DataCell()
           
 
Method Summary
 boolean equals(Object o)
          Implements the equals method which returns true only if both cells are of the same class and equalsDataCell(DataCell) returns true.
protected abstract  boolean equalsDataCell(DataCell dc)
          Derived classes implement their specific equals function here.
 DataType getType()
          Returns this cell's DataType.
abstract  int hashCode()
          This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.
 boolean isMissing()
          Returns true if this represents missing cell, false otherwise.
(package private)  boolean isMissingInternal()
          Internal implementation of isMissing().
abstract  String toString()
          Returns the String representation of this cell's value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataCell

public DataCell()
Method Detail

getType

public final DataType getType()
Returns this cell's DataType. This method is provided for convenience only, it is a shortcut for DataType.getType(o.getClass()), where o is the runtime DataCell object.

Returns:
the DataType
See Also:
DataType.getType(Class)

isMissing

public final boolean isMissing()
Returns true if this represents missing cell, false otherwise. The default implementation returns false. If you need a missing cell use the static method DataType.getMissingCell().

Returns:
true if the cell represents a missing value, false otherwise
See Also:
DataType.getMissingCell()

isMissingInternal

boolean isMissingInternal()
Internal implementation of isMissing(). It will return false and is only overridden in the DataType.getMissingCell() implementation.

Returns:
false

toString

public abstract String toString()
Returns the String representation of this cell's value.

Overrides:
toString in class Object
Returns:
a String representation of this cell's value

equals

public final boolean equals(Object o)
Implements the equals method which returns true only if both cells are of the same class and equalsDataCell(DataCell) returns true. For that, this final method calls the type specific equalsDataCell(DataCell) method, which all derived DataCells must provide. This method handles the missing value and null cases, in all other cases it delegates to the specific method.

Overrides:
equals in class Object
Parameters:
o - the other object to check
Returns:
true if this instance and the given object are instances of the same class and of equal value (or both representing missing values)

equalsDataCell

protected abstract boolean equalsDataCell(DataCell dc)
Derived classes implement their specific equals function here. The argument is guaranteed to be not null or a missing value, to be of the same class like this.

Parameters:
dc - the cell to compare this to
Returns:
true if this is equal to the argument, false if not

hashCode

public abstract int hashCode()
This method must be implemented in order to ensure that two equal DataCell objects return the same hash code.

Overrides:
hashCode in class Object
Returns:
the hash code of your specific DataCell
See Also:
Object.hashCode(), equals(java.lang.Object)


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.