Class SpreadSheetReplaceCellValue

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

    public class SpreadSheetReplaceCellValue
    extends AbstractInPlaceSpreadSheetTransformer
    Replaces cell values that match a regular expression with a predefined value.

    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: SpreadSheetReplaceCellValue
     
    -annotation <adams.core.base.BaseText> (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
     
    -no-copy <boolean> (property: noCopy)
        If enabled, no copy of the spreadsheet is created before processing it.
        default: false
     
    -find <adams.core.base.BaseRegExp> (property: find)
        The string to find (a regular expression).
        default: find
     
    -replace <java.lang.String> (property: replace)
        The string to replace the occurrences with.
        default: 
     
    -all <boolean> (property: replaceAll)
        If set to true, then all occurrences will be replaced; otherwise only the 
        first.
        default: false
     
    -placeholder <boolean> (property: replaceContainsPlaceholder)
        Set this to true to enable automatic placeholder expansion for the replacement 
        string.
        default: false
     
    -variable <boolean> (property: replaceContainsVariable)
        Set this to true to enable automatic variable expansion for the replacement 
        string.
        default: false
     
    -scope <DATA_ONLY|HEADER_ONLY|HEADER_AND_DATA> (property: scope)
        Determines the scope of the find/replace action.
        default: DATA_ONLY
     
    -position <adams.data.spreadsheet.SpreadSheetColumnRange> (property: position)
        The position of the columns to process.
        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 '...'; apart from column names (case-sensitive), the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_ACTUALREPLACE

        public static final String BACKUP_ACTUALREPLACE
        the key for storing the current actual replace in the backup.
        See Also:
        Constant Field Values
      • m_Find

        protected BaseRegExp m_Find
        the string to find.
      • m_Replace

        protected String m_Replace
        the replacement string.
      • m_ActualReplace

        protected String m_ActualReplace
        the actual replacement string (after optional placeholder expansion).
      • m_ReplaceAll

        protected boolean m_ReplaceAll
        whether to replace all or only the first occurrence.
      • m_ReplaceContainsPlaceholder

        protected boolean m_ReplaceContainsPlaceholder
        whether the replace string contains a placeholder, which needs to be expanded first.
      • m_ReplaceContainsVariable

        protected boolean m_ReplaceContainsVariable
        whether the replace string contains a variable, which needs to be expanded first.
    • Constructor Detail

      • SpreadSheetReplaceCellValue

        public SpreadSheetReplaceCellValue()
    • Method Detail

      • setFind

        public void setFind​(BaseRegExp value)
        Sets the string to find (regular expression).
        Parameters:
        value - the string
      • getFind

        public BaseRegExp getFind()
        Returns the string to find (regular expression).
        Returns:
        the string
      • findTipText

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

        public void setReplace​(String value)
        Sets the string to replace the occurrences with.
        Parameters:
        value - the string
      • getReplace

        public String getReplace()
        Returns the string to replace the occurences with.
        Returns:
        the string
      • replaceTipText

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

        public void setReplaceAll​(boolean value)
        Sets whether all occurrences are replaced or only the first.
        Parameters:
        value - true if all are to be replaced, false if only the first
      • getReplaceAll

        public boolean getReplaceAll()
        Returns whether all occurrences are replaced or only the first one.
        Returns:
        true if all are to be replaced, false if only the first
      • replaceAllTipText

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

        public void setReplaceContainsPlaceholder​(boolean value)
        Sets whether the replace string contains a placeholder which needs to be expanded first.
        Parameters:
        value - true if replace string contains a placeholder
      • getReplaceContainsPlaceholder

        public boolean getReplaceContainsPlaceholder()
        Returns whether the replace string contains a placeholder which needs to be expanded first.
        Returns:
        true if replace string contains a placeholder
      • replaceContainsPlaceholderTipText

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

        public void setReplaceContainsVariable​(boolean value)
        Sets whether the replace string contains a variable which needs to be expanded first.
        Parameters:
        value - true if replace string contains a variable
      • getReplaceContainsVariable

        public boolean getReplaceContainsVariable()
        Returns whether the replace string contains a variable which needs to be expanded first.
        Returns:
        true if replace string contains a variable
      • replaceContainsVariableTipText

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

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

        public void setPosition​(SpreadSheetColumnRange value)
        Sets the position of the columns to process.
        Parameters:
        value - the position
      • getPosition

        public SpreadSheetColumnRange getPosition()
        Returns the position of the columns to process.
        Returns:
        the position
      • positionTipText

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

        protected String process​(String s)
        Processes the string.
        Parameters:
        s - the string to process
        Returns:
        the processed string
      • doExecute

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