adams.flow.transformer
Class SpreadSheetReplaceCellValue

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.transformer.AbstractTransformer
                  extended by adams.flow.transformer.AbstractSpreadSheetTransformer
                      extended by adams.flow.transformer.AbstractInPlaceSpreadSheetTransformer
                          extended by adams.flow.transformer.SpreadSheetReplaceCellValue
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, 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.core.io.SpreadSheet
- generates:
   adams.core.io.SpreadSheet

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to
    the console (0 = off).
    default: 0
    minimum: 0
 
-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 (property: skip)
    If set to true, transformation is skipped and the input token is just forwarded
    as it is.
 
-stop-flow-on-error (property: stopFlowOnError)
    If set to true, the flow gets stopped in case this actor encounters an error;
     useful for critical actors.
 
-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 (property: replaceAll)
    If set to true, then all occurrences will be replaced; otherwise only the
    first.
 
-placeholder (property: replaceContainsPlaceholder)
    Set this to true to enable automatic placeholder expansion for the replacement
    string.
 
-variable (property: replaceContainsVariable)
    Set this to true to enable automatic variable expansion for the replacement
    string.
 
-scope <DATA_ONLY|HEADER_ONLY|HEADER_AND_DATA> (property: scope)
    Determines the scope of the find/replace action.
    default: DATA_ONLY
 

Version:
$Revision: 6830 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Nested Class Summary
static class SpreadSheetReplaceCellValue.Scope
          Defines the scope of the replace.
 
Field Summary
static String BACKUP_ACTUALREPLACE
          the key for storing the current actual replace in the backup.
protected  String m_ActualReplace
          the actual replacement string (after optional placeholder expansion).
protected  BaseRegExp m_Find
          the string to find.
protected  String m_Replace
          the replacement string.
protected  boolean m_ReplaceAll
          whether to replace all or only the first occurrence.
protected  boolean m_ReplaceContainsPlaceholder
          whether the replace string contains a placeholder, which needs to be expanded first.
protected  boolean m_ReplaceContainsVariable
          whether the replace string contains a variable, which needs to be expanded first.
protected  SpreadSheetReplaceCellValue.Scope m_Scope
          the scope of the replace.
 
Fields inherited from class adams.flow.transformer.AbstractInPlaceSpreadSheetTransformer
m_NoCopy
 
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
 
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_ScopeHandler, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
 
Constructor Summary
SpreadSheetReplaceCellValue()
           
 
Method Summary
protected  Hashtable<String,Object> backupState()
          Backs up the current state of the actor before update the variables.
 void defineOptions()
          Adds options to the internal list of options.
protected  String doExecute()
          Executes the flow item.
 String findTipText()
          Returns the tip text for this property.
 BaseRegExp getFind()
          Returns the string to find (regular expression).
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 String getReplace()
          Returns the string to replace the occurences with.
 boolean getReplaceAll()
          Returns whether all occurrences are replaced or only the first one.
 boolean getReplaceContainsPlaceholder()
          Returns whether the replace string contains a placeholder which needs to be expanded first.
 boolean getReplaceContainsVariable()
          Returns whether the replace string contains a variable which needs to be expanded first.
 SpreadSheetReplaceCellValue.Scope getScope()
          Returns the scope of the replace.
 String globalInfo()
          Returns a string describing the object.
protected  String process(String s)
          Processes the string.
protected  void pruneBackup()
          Removes entries from the backup.
 String replaceAllTipText()
          Returns the tip text for this property.
 String replaceContainsPlaceholderTipText()
          Returns the tip text for this property.
 String replaceContainsVariableTipText()
          Returns the tip text for this property.
 String replaceTipText()
          Returns the tip text for this property.
protected  void restoreState(Hashtable<String,Object> state)
          Restores the state of the actor before the variables got updated.
 String scopeTipText()
          Returns the tip text for this property.
 void setFind(BaseRegExp value)
          Sets the string to find (regular expression).
 void setReplace(String value)
          Sets the string to replace the occurrences with.
 void setReplaceAll(boolean value)
          Sets whether all occurrences are replaced or only the first.
 void setReplaceContainsPlaceholder(boolean value)
          Sets whether the replace string contains a placeholder which needs to be expanded first.
 void setReplaceContainsVariable(boolean value)
          Sets whether the replace string contains a variable which needs to be expanded first.
 void setScope(SpreadSheetReplaceCellValue.Scope value)
          Sets the scope of the replace.
 String setUp()
          Initializes the item for flow execution.
 
Methods inherited from class adams.flow.transformer.AbstractInPlaceSpreadSheetTransformer
getNoCopy, noCopyTipText, setNoCopy
 
Methods inherited from class adams.flow.transformer.AbstractSpreadSheetTransformer
accepts, generates
 
Methods inherited from class adams.flow.transformer.AbstractTransformer
execute, hasPendingOutput, input, output, postExecute, reset, wrapUp
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, preExecute, pruneBackup, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, debug, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setVariables, sizeOf, stopExecution, stopExecution, variableChanged
 
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
 
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
 

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.


m_Scope

protected SpreadSheetReplaceCellValue.Scope m_Scope
the scope of the replace.

Constructor Detail

SpreadSheetReplaceCellValue

public SpreadSheetReplaceCellValue()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractInPlaceSpreadSheetTransformer

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface QuickInfoSupporter
Specified by:
getQuickInfo in interface Actor
Overrides:
getQuickInfo in class AbstractActor
Returns:
null if no info available, otherwise short string

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.

setScope

public void setScope(SpreadSheetReplaceCellValue.Scope value)
Sets the scope of the replace.

Parameters:
value - the scope

getScope

public SpreadSheetReplaceCellValue.Scope getScope()
Returns the scope of the replace.

Returns:
the scope

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.

pruneBackup

protected void pruneBackup()
Removes entries from the backup.

Overrides:
pruneBackup in class AbstractActor

backupState

protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.

Overrides:
backupState in class AbstractTransformer
Returns:
the backup

restoreState

protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.

Overrides:
restoreState in class AbstractTransformer
Parameters:
state - the backup of the state to restore from

setUp

public String setUp()
Initializes the item for flow execution.

Specified by:
setUp in interface Actor
Overrides:
setUp in class AbstractActor
Returns:
null if everything is fine, otherwise error message

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


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.