org.knime.core.node.port.pmml
Class PMMLPortObject

java.lang.Object
  extended by org.knime.core.node.port.pmml.PMMLPortObject
All Implemented Interfaces:
PortObject
Direct Known Subclasses:
PMMLAssociationRulePortObject, PMMLClusterPortObject, PMMLDecisionTreePortObject, PMMLNeuralNetworkPortObject, PMMLRegressionPortObject, PMMLSVMPortObject

public abstract class PMMLPortObject
extends Object
implements PortObject

Author:
Fabian Dill, University of Konstanz

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.knime.core.node.port.PortObject
PortObject.PortObjectSerializer<T extends PortObject>
 
Field Summary
protected static String CDATA
          Constant for CDATA.
protected static String DATA_DICT
          Constant for DataDictionary.
protected static String DATA_FIELD
          Constant for DataField.
static String PMML_V3_0
          Constant for version 3.0.
static String PMML_V3_1
          Constant for version 3.1.
static String PMML_V3_2
          Constant for version 3.2.
protected static String VALUE
          Constant for Value.
 
Constructor Summary
PMMLPortObject()
          Default constructor necessary for loading.
PMMLPortObject(PMMLPortObjectSpec spec, PMMLModelType type)
           
 
Method Summary
 boolean addPMMLContentHandler(String id, PMMLContentHandler defaultHandler)
          Adds a content handler to the master content handler.
static String getLocalSchemaLocation(String version)
          Based on the version number the local schema location is returned.
 PMMLModelType getModelType()
           
 PMMLContentHandler getPMMLContentHandler(String id)
           
static PortObject.PortObjectSerializer<PMMLPortObject> getPortObjectSerializer()
          Static serializer as demanded from PortObject framework.
 PMMLPortObjectSpec getSpec()
          Get specification to this port object.
abstract  String getSummary()
          Get a short summary of this PortObject.
 JComponent[] getViews()
          The returned views are displayed in the out port view of the referring node.
 void loadFrom(PMMLPortObjectSpec spec, InputStream in, String version)
           
 void save(OutputStream out)
          Writes the port object to valid PMML.
protected abstract  void writePMMLModel(TransformerHandler handler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CDATA

protected static final String CDATA
Constant for CDATA.

See Also:
Constant Field Values

DATA_DICT

protected static final String DATA_DICT
Constant for DataDictionary.

See Also:
Constant Field Values

DATA_FIELD

protected static final String DATA_FIELD
Constant for DataField.

See Also:
Constant Field Values

VALUE

protected static final String VALUE
Constant for Value.

See Also:
Constant Field Values

PMML_V3_0

public static final String PMML_V3_0
Constant for version 3.0. Can be used as argument for the load method.

See Also:
Constant Field Values

PMML_V3_1

public static final String PMML_V3_1
Constant for version 3.1. Can be used as argument for the load method.

See Also:
Constant Field Values

PMML_V3_2

public static final String PMML_V3_2
Constant for version 3.2. Can be used as argument for the load method.

See Also:
Constant Field Values
Constructor Detail

PMMLPortObject

public PMMLPortObject()
Default constructor necessary for loading. Derived classes also must provide a default constructor, otherwise loading will fail.


PMMLPortObject

public PMMLPortObject(PMMLPortObjectSpec spec,
                      PMMLModelType type)
Parameters:
spec - the referring PMMLPortObjectSpec
type - the type of the PMML model
Method Detail

getLocalSchemaLocation

public static String getLocalSchemaLocation(String version)
Based on the version number the local schema location is returned.

Parameters:
version - version 3.0 - 3.2
Returns:
the location of the local schema

getPortObjectSerializer

public static final PortObject.PortObjectSerializer<PMMLPortObject> getPortObjectSerializer()
Static serializer as demanded from PortObject framework.

Returns:
serializer for PMML (reads and writes PMML files)

addPMMLContentHandler

public boolean addPMMLContentHandler(String id,
                                     PMMLContentHandler defaultHandler)
Adds a content handler to the master content handler. The master content handler forwards all relevant events from PMML file parsing to all registered content handlers.

Parameters:
id - to later on retrieve the registered content handler
defaultHandler - specialized content handler interested in certain parts of the PMML file (ClusteringModel, TreeModel, etc.)
Returns:
true if the handler was added, false if it is already registered

getPMMLContentHandler

public PMMLContentHandler getPMMLContentHandler(String id)
Parameters:
id - the id which was used for registration of the handler
Returns:
the handler registered with this id or null if no handler with this id can be found

getModelType

public PMMLModelType getModelType()
Returns:
the type of model
See Also:
PMMLModelType

save

public void save(OutputStream out)
          throws SAXException,
                 IOException,
                 TransformerConfigurationException
Writes the port object to valid PMML. Subclasses should not override this method but the writePMMLModel(TransformerHandler) instead.

Parameters:
out - zipped stream which reads the PMML file
Throws:
SAXException - if something goes wrong during writing of PMML
IOException - if the file cannot be written to the directory
TransformerConfigurationException - if something goes wrong with the transformation handler

getSummary

public abstract String getSummary()
Get a short summary of this PortObject. The return value will be shown in a node port's tooltip, for instance.

Specified by:
getSummary in interface PortObject
Returns:
Summary of the object's content, suitable for a tooltip. Empty strings and null result values are ok (though not encouraged).

loadFrom

public void loadFrom(PMMLPortObjectSpec spec,
                     InputStream in,
                     String version)
              throws SAXException,
                     ParserConfigurationException,
                     IOException
Parameters:
spec - the referring spec of this object
in - the input stream to write to
version - the version (3.0 - 3.1)
Throws:
SAXException - if something goes wrong during writing
ParserConfigurationException - if the parser cannot be instantiated
IOException - if the file cannot be found

getSpec

public PMMLPortObjectSpec getSpec()
Get specification to this port object. That is, the corresponding PortObjectSpec which is used to configure any successor node after execution, e.g. a BufferedDataTable can return a DataTableSpec.

Subclasses should narrow the return type if possible.

Specified by:
getSpec in interface PortObject
Returns:
underlying PortObjectSpec or any derived spec, never null.

writePMMLModel

protected abstract void writePMMLModel(TransformerHandler handler)
                                throws SAXException
Parameters:
handler - the handler responsible for writing the PMML
Throws:
SAXException - if something goes wrong during writing the PMML

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


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.