Class SpreadSheetVariableRowIterator

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LenientModeSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable

    public class SpreadSheetVariableRowIterator
    extends AbstractTransformer
    implements LenientModeSupporter
    Iterates through a defined range of rows. In each iteration the cell values of the defined column range are mapped to variables.
    By default the (cleaned up) header names of the columns are used as variable names. To avoid name clashes, a prefix can be chosen for the variable names.
    The subset of columns of the row in the current iteration can be output as spreadsheet well (computationally expensive). By default, the complete spreadsheet is forwarded as is.

    Input/output:
    - accepts:
       adams.data.spreadsheet.SpreadSheet
    - generates:
       adams.data.spreadsheet.SpreadSheet


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: SpreadSheetVariableRowIterator
     
    -annotation <adams.core.base.BaseAnnotation> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
        default: false
     
    -rows <adams.core.Range> (property: rows)
        The rows to retrieve the values from; A range is a comma-separated list 
        of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(..
        .)' inverts the range '...'; column names (case-sensitive) as well as the 
        following placeholders can be used: first, second, third, last_2, last_1,
         last
        default: first-last
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -columns <adams.data.spreadsheet.SpreadSheetColumnRange> (property: columns)
        The columns to retrieve the values from; A range is a comma-separated list 
        of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(..
        .)' inverts the range '...'; column names (case-sensitive) as well as the 
        following placeholders can be used: first, second, third, last_2, last_1,
         last
        default: first-last
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last
     
    -variable-prefix <java.lang.String> (property: variablePrefix)
        The prefix to prepend the header names with to make up the variable name.
        default: 
     
    -missing-value <java.lang.String> (property: missingValue)
        The value to use as variable value in case of missing cells.
        default: 
     
    -output-modified <boolean> (property: outputModified)
        If enabled, the modified spreadsheet (current row with subset of columns
        ) is output instead of the full dataset (computationally expensive).
        default: false
     
    -lenient <boolean> (property: lenient)
        If enabled, then no error message is generated if no rows are found.
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_QUEUE

        public static final String BACKUP_QUEUE
        the key for storing the queue of rows to process.
        See Also:
        Constant Field Values
      • m_Rows

        protected Range m_Rows
        the range of rows to use.
      • m_VariablePrefix

        protected String m_VariablePrefix
        the prefix for the variables.
      • m_MissingValue

        protected String m_MissingValue
        the value to use for missing cells.
      • m_Sheet

        protected SpreadSheet m_Sheet
        the underlying sheet.
      • m_ColumnIndices

        protected int[] m_ColumnIndices
        the column indices.
      • m_OutputModified

        protected boolean m_OutputModified
        whether to output the modified spreadsheet.
      • m_Lenient

        protected boolean m_Lenient
        whether to suppress the error message if no rows selected.
    • Constructor Detail

      • SpreadSheetVariableRowIterator

        public SpreadSheetVariableRowIterator()
    • Method Detail

      • reset

        protected void reset()
        Resets the actor.
        Overrides:
        reset in class AbstractActor
      • setColumns

        public void setColumns​(SpreadSheetColumnRange value)
        Sets the columns to retrieve the values from.
        Parameters:
        value - the columns
      • getColumns

        public SpreadSheetColumnRange getColumns()
        Returns the columns to retrieve the values from.
        Returns:
        the columns
      • columnsTipText

        public String columnsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setRows

        public void setRows​(Range value)
        Sets the rows to retrieve the values from.
        Parameters:
        value - the rows
      • getRows

        public Range getRows()
        Returns the rows to retrieve the values from.
        Returns:
        the rows
      • rowsTipText

        public String rowsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setVariablePrefix

        public void setVariablePrefix​(String value)
        Sets the prefix for the variables (prefix + header).
        Parameters:
        value - the prefix
      • getVariablePrefix

        public String getVariablePrefix()
        Returns the prefix for the variables (prefix + header).
        Returns:
        the prefix
      • variablePrefixTipText

        public String variablePrefixTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setMissingValue

        public void setMissingValue​(String value)
        Sets the value to use for missing cells.
        Parameters:
        value - the value for missing cells
      • getMissingValue

        public String getMissingValue()
        Returns the value to use for missing cells.
        Returns:
        the value for missing cells
      • missingValueTipText

        public String missingValueTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setOutputModified

        public void setOutputModified​(boolean value)
        Sets whether to output the modified spreadsheet (current row, subset of columns) instead of the full one.
        Parameters:
        value - true if to output modified spreadsheet
      • getOutputModified

        public boolean getOutputModified()
        Returns whether to output the modified spreadsheet (current row, subset of columns) instead of the full one.
        Returns:
        true if to output modified spreadsheet
      • outputModifiedTipText

        public String outputModifiedTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setLenient

        public void setLenient​(boolean value)
        Sets whether to suppress error message if no rows found.
        Specified by:
        setLenient in interface LenientModeSupporter
        Parameters:
        value - true if to suppress
      • getLenient

        public boolean getLenient()
        Returns whether to suppress error message if no rows found.
        Specified by:
        getLenient in interface LenientModeSupporter
        Returns:
        true if to suppress
      • lenientTipText

        public String lenientTipText()
        Returns the tip text for this property.
        Specified by:
        lenientTipText in interface LenientModeSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        the Class of objects that can be processed
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        the Class of the generated tokens
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message