Package weka.knowledgeflow
Class Data
- java.lang.Object
-
- weka.knowledgeflow.Data
-
- All Implemented Interfaces:
java.io.Serializable
public class Data extends java.lang.Object implements java.io.SerializableClass for encapsulating data to be transferred between Knowledge Flow steps over a particular connection type. Typical usage involves constructing a Data object with a given connection name and then setting one or more pieces of "payload" data to encapsulate. Usually there is a primary payload that is associated with the connection name itself (there is a constructor that takes both the connection name and the primary payload data). Further auxiliary data items can be added via the setPayloadElement() method.
Standard connection types are defined as constants in the StepManager class. There is nothing to prevent clients from using their own connection types (as these are just string identifiers).
Typical usage in a client step (transferring an training instances object):
Instances train = ... Data myData = new Data(StepManager.CON_TRAININGSET, train); getStepManager().outputData(myData);- Version:
- $Revision: $
- Author:
- mhall{[at]}pentaho{[dot]}com
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Data()Empty constructor - no connection name; no payloadData(java.lang.String connectionName)Construct a Data object with just a connection nameData(java.lang.String connectionName, java.lang.Object primaryPayload)Construct a Data object with a connection name and a primary payload object to associate with the connection name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearPayload()Clear all payload elements from this Data objectjava.lang.StringgetConnectionName()Get the connection name associated with this Data object<T> TgetPayloadElement(java.lang.String name)Get a payload element from this Data object.<T> TgetPayloadElement(java.lang.String name, T defaultValue)Get a payload element from this Data object.<T> TgetPrimaryPayload()Get the primary payload of this data object (i.e.StepgetSourceStep()Get the source step producing this Data objectbooleanisIncremental()Return true if the connection specified for this data object is incrementalvoidsetConnectionName(java.lang.String name)Set the connection name for this Data objectvoidsetPayloadElement(java.lang.String name, java.lang.Object value)Set a payload element to encapsulate in this Data object.voidsetSourceStep(Step sourceStep)Set the source step of producing this Data object
-
-
-
Constructor Detail
-
Data
public Data()
Empty constructor - no connection name; no payload
-
Data
public Data(java.lang.String connectionName)
Construct a Data object with just a connection name- Parameters:
connectionName- the connection name
-
Data
public Data(java.lang.String connectionName, java.lang.Object primaryPayload)Construct a Data object with a connection name and a primary payload object to associate with the connection name- Parameters:
connectionName- connection nameprimaryPayload- primary payload object (i.e. is keyed against the connection name)
-
-
Method Detail
-
setSourceStep
public void setSourceStep(Step sourceStep)
Set the source step of producing this Data object- Parameters:
sourceStep- the source step
-
getSourceStep
public Step getSourceStep()
Get the source step producing this Data object- Returns:
- the source step producing the data object
-
setConnectionName
public void setConnectionName(java.lang.String name)
Set the connection name for this Data object- Parameters:
name- the name of the connection
-
getConnectionName
public java.lang.String getConnectionName()
Get the connection name associated with this Data object- Returns:
- the connection name
-
getPrimaryPayload
public <T> T getPrimaryPayload()
Get the primary payload of this data object (i.e. the data associated with the connection name)- Type Parameters:
T- the type of the primary payload- Returns:
- the primary payload data (or null if there is no data associated with the connection)
-
getPayloadElement
public <T> T getPayloadElement(java.lang.String name)
Get a payload element from this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.- Parameters:
name- the name of the payload element to get- Returns:
- the named payload element, or null if it does not exist in this Data object
-
getPayloadElement
public <T> T getPayloadElement(java.lang.String name, T defaultValue)Get a payload element from this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.- Type Parameters:
T- the type of the payload element to get- Parameters:
name- the name of the payload element to getdefaultValue- a default value if the named element does not exist- Returns:
- the payload element, or the supplied default value.
-
setPayloadElement
public void setPayloadElement(java.lang.String name, java.lang.Object value)Set a payload element to encapsulate in this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.- Parameters:
name- the name of the payload element to encapsulatevalue- the value of the payload element
-
clearPayload
public void clearPayload()
Clear all payload elements from this Data object
-
isIncremental
public boolean isIncremental()
Return true if the connection specified for this data object is incremental- Returns:
- true if the connection for this data object is incremental
-
-