org.knime.core.node.port
Class AbstractSimplePortObject

java.lang.Object
  extended by org.knime.core.node.port.AbstractSimplePortObject
All Implemented Interfaces:
PortObject
Direct Known Subclasses:
BasisFunctionPortObject, DiscretizationModel, NaiveBayesPortObject, NormalizerPortObject, PCAModelPortObject, SotaPortObject, ViewPropertyPortObject

public abstract class AbstractSimplePortObject
extends Object
implements PortObject

Abstract implementation of basic port objects that save and load themselves from ModelContentRO objects. This class should be used in cases where the content of a model can be easily broke up into basic types (such as String, int, double, ...) and array of those.

Subclasses must provide an empty no-arg constructor with public scope (which will be used to restore the content). They are encouraged to also provide a convenience access member such as

 public static final PortType TYPE = new PortType(FooModelPortObject.class);
 
and to narrow the return type of the getSpec() method (most commonly used are specs of type DataTableSpec, whereby the columns reflect the required input attributes of a model), or AbstractSimplePortObjectSpec Derived classes don't need to provide a static serializer method as required by the interface PortObject.

Author:
Bernd Wiswedel, University of Konstanz

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.knime.core.node.port.PortObject
PortObject.PortObjectSerializer<T extends PortObject>
 
Constructor Summary
AbstractSimplePortObject()
          Public no-arg constructor.
 
Method Summary
 boolean equals(Object oport)
          Method compares both ModelContent objects that first need to be saved by calling save(ModelContentWO, ExecutionMonitor).
static PortObject.PortObjectSerializer<AbstractSimplePortObject> getPortObjectSerializer()
          Abstract serializer method as required by interface PortObject.
 JComponent[] getViews()
          The returned views are displayed in the out port view of the referring node.
 int hashCode()
          Method computes the hash code as defined by the underlying ModelContent object that first need to be saved by calling save(ModelContentWO, ExecutionMonitor).
protected abstract  void load(ModelContentRO model, PortObjectSpec spec, ExecutionMonitor exec)
          Loads the content into the freshly instantiated object.
protected abstract  void save(ModelContentWO model, ExecutionMonitor exec)
          Saves this object to model content object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.knime.core.node.port.PortObject
getSpec, getSummary
 

Constructor Detail

AbstractSimplePortObject

public AbstractSimplePortObject()
Public no-arg constructor. Subclasses must also provide such a constructor in order to allow the serializer to instantiate them using reflection.

Method Detail

getPortObjectSerializer

public static final PortObject.PortObjectSerializer<AbstractSimplePortObject> getPortObjectSerializer()
Abstract serializer method as required by interface PortObject.

Returns:
A serializer that reads/writes any implementation of this class.

save

protected abstract void save(ModelContentWO model,
                             ExecutionMonitor exec)
                      throws CanceledExecutionException
Saves this object to model content object.

Parameters:
model - To save to.
exec - For progress/cancelation.
Throws:
CanceledExecutionException - If canceled.

load

protected abstract void load(ModelContentRO model,
                             PortObjectSpec spec,
                             ExecutionMonitor exec)
                      throws InvalidSettingsException,
                             CanceledExecutionException
Loads the content into the freshly instantiated object. This method is called at most once in the life time of the object (after the serializer has created a new object using the public no-arg constructor.)

Parameters:
model - To load from.
spec - The accompanying spec (which can be safely cast to the expected class).
exec - For progress/cancelation.
Throws:
InvalidSettingsException - If settings are incomplete/deficient.
CanceledExecutionException - If canceled.

getViews

public JComponent[] getViews()
The returned views are displayed in the out port view of the referring node. Each component is displayed in an extra tab. The name of the component is used as the title for the tab. It is important that no external members are kept in the component so it can be deleted, when the port object is deleted. If the port object has no view return an empty array.

Specified by:
getViews in interface PortObject
Returns:
an array of views for the port object, each displayed as a tab in the out port view

equals

public boolean equals(Object oport)
Method compares both ModelContent objects that first need to be saved by calling save(ModelContentWO, ExecutionMonitor). Override this method in order to compare both objects more efficiently.

Overrides:
equals in class Object

hashCode

public int hashCode()
Method computes the hash code as defined by the underlying ModelContent object that first need to be saved by calling save(ModelContentWO, ExecutionMonitor). Override this method in order to compute the hash code more efficiently.

Overrides:
hashCode in class 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.