Package adams.flow.transformer
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSpreadSheetReplaceCellValue.ScopeDefines the scope of the replace.
-
Field Summary
Fields Modifier and Type Field Description static StringBACKUP_ACTUALREPLACEthe key for storing the current actual replace in the backup.protected Stringm_ActualReplacethe actual replacement string (after optional placeholder expansion).protected BaseRegExpm_Findthe string to find.protected SpreadSheetColumnRangem_Positionthe position of the columns to process.protected Stringm_Replacethe replacement string.protected booleanm_ReplaceAllwhether to replace all or only the first occurrence.protected booleanm_ReplaceContainsPlaceholderwhether the replace string contains a placeholder, which needs to be expanded first.protected booleanm_ReplaceContainsVariablewhether the replace string contains a variable, which needs to be expanded first.protected SpreadSheetReplaceCellValue.Scopem_Scopethe 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_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description SpreadSheetReplaceCellValue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>backupState()Backs up the current state of the actor before update the variables.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.StringfindTipText()Returns the tip text for this property.BaseRegExpgetFind()Returns the string to find (regular expression).SpreadSheetColumnRangegetPosition()Returns the position of the columns to process.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.StringgetReplace()Returns the string to replace the occurences with.booleangetReplaceAll()Returns whether all occurrences are replaced or only the first one.booleangetReplaceContainsPlaceholder()Returns whether the replace string contains a placeholder which needs to be expanded first.booleangetReplaceContainsVariable()Returns whether the replace string contains a variable which needs to be expanded first.SpreadSheetReplaceCellValue.ScopegetScope()Returns the scope of the replace.StringglobalInfo()Returns a string describing the object.StringpositionTipText()Returns the tip text for this property.protected Stringprocess(String s)Processes the string.protected voidpruneBackup()Removes entries from the backup.StringreplaceAllTipText()Returns the tip text for this property.StringreplaceContainsPlaceholderTipText()Returns the tip text for this property.StringreplaceContainsVariableTipText()Returns the tip text for this property.StringreplaceTipText()Returns the tip text for this property.protected voidrestoreState(Hashtable<String,Object> state)Restores the state of the actor before the variables got updated.StringscopeTipText()Returns the tip text for this property.voidsetFind(BaseRegExp value)Sets the string to find (regular expression).voidsetPosition(SpreadSheetColumnRange value)Sets the position of the columns to process.voidsetReplace(String value)Sets the string to replace the occurrences with.voidsetReplaceAll(boolean value)Sets whether all occurrences are replaced or only the first.voidsetReplaceContainsPlaceholder(boolean value)Sets whether the replace string contains a placeholder which needs to be expanded first.voidsetReplaceContainsVariable(boolean value)Sets whether the replace string contains a variable which needs to be expanded first.voidsetScope(SpreadSheetReplaceCellValue.Scope value)Sets the scope of the replace.StringsetUp()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
currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, wrapUp
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
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, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
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.
-
m_Position
protected SpreadSheetColumnRange m_Position
the position of the columns to process.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractInPlaceSpreadSheetTransformer
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- 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.
-
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.
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackupin classAbstractActor- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupStatein classAbstractTransformer- Returns:
- the backup
- See Also:
AbstractActor.updateVariables(),AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreStatein classAbstractTransformer- Parameters:
state- the backup of the state to restore from- See Also:
AbstractActor.updateVariables(),AbstractActor.backupState()
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
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:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
-