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.Serializable

  Class 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 and Description
    `Data()` Empty constructor - no connection name; no payload
    `Data(java.lang.String connectionName)` Construct a Data object with just a connection name
    `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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearPayload()` Clear all payload elements from this Data object
    `java.lang.String` | `getConnectionName()` Get the connection name associated with this Data object
    `<T> T` | `getPayloadElement(java.lang.String name)` Get a payload element from this Data object.
    `<T> T` | `getPayloadElement(java.lang.String name, T defaultValue)` Get a payload element from this Data object.
    `<T> T` | `getPrimaryPayload()` Get the primary payload of this data object (i.e.
    `Step` | `getSourceStep()` Get the source step producing this Data object
    `boolean` | `isIncremental()` Return true if the connection specified for this data object is incremental
    `void` | `setConnectionName(java.lang.String name)` Set the connection name for this Data object
    `void` | `setPayloadElement(java.lang.String name, java.lang.Object value)` Set a payload element to encapsulate in this Data object.
    `void` | `setSourceStep(Step sourceStep)` Set the source step of producing this Data object

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 name
        `primaryPayload` - 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 get
        `defaultValue` - 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 encapsulate
        `value` - 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