Package adams.flow.transformer
Class StringRangeCut
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,ErrorHandler
,InputConsumer
,OutputProducer
,Serializable
,Comparable
public class StringRangeCut extends AbstractStringOperation
Cuts out a parts of a string. The cut can be either specified as fixed character positions or as fields from delimited columns.
When cutting multiple ranges, a 'glue' for the sub-strings can be provided.
Input/output:
- accepts:
java.lang.String
java.lang.String[]
- generates:
java.lang.String
java.lang.String[]
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: StringRangeCut
-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.
-type <CHARACTER_POSITIONS|DELIMITED_FIELDS> (property: type) The type of cut operation to perform. default: CHARACTER_POSITIONS
-range <java.lang.String> (property: range) The range of characters or fields to cut out; 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 default: 1
-delimiter <java.lang.String> (property: delimiter) The delimiter to use in case of DELIMITED_FIELDS; \t gets automatically converted into its character counterpart. default: \\t
-glue <java.lang.String> (property: glue) The 'glue' string to use for joining the sub-strings from the ranges; e.g. , \t gets automatically converted into its character counterpart. default:
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StringRangeCut.Type
Enumeration for whether to use character positions of delimited fields.
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Delimiter
the field delimiter.protected String
m_Glue
the glue for the sub-strings.protected Range
m_Range
the range.protected StringRangeCut.Type
m_Type
what type of cutting to perform.-
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 StringRangeCut()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.String
delimiterTipText()
Returns the tip text for this property.String
getDelimiter()
Returns the delimiter in use.String
getGlue()
Returns the "glue" to use for joining the substrings.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.Range
getRange()
Returns the range of characters/fields to extract.StringRangeCut.Type
getType()
Returns the type of cut operation to perform.String
globalInfo()
Returns a string describing the object.String
glueTipText()
Returns the tip text for this property.protected void
initialize()
Initializes the members.protected String
process(String s, int index)
Processes the string.String
rangeTipText()
Returns the tip text for this property.void
setDelimiter(String value)
Sets the delimiter to use.void
setGlue(String value)
Sets the "glue" to use for joining the substrings.void
setRange(Range value)
Sets the range of characters/fields to extract.void
setType(StringRangeCut.Type value)
Sets the type of cut operation to perform.String
typeTipText()
Returns the tip text for this property.-
Methods inherited from class adams.flow.transformer.AbstractStringOperation
accepts, doExecute, generates
-
Methods inherited from class adams.flow.transformer.AbstractTransformer
backupState, currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, restoreState, 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, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, 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, setUp, 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
-
m_Type
protected StringRangeCut.Type m_Type
what type of cutting to perform.
-
m_Range
protected Range m_Range
the range.
-
m_Delimiter
protected String m_Delimiter
the field delimiter.
-
m_Glue
protected String m_Glue
the glue for the sub-strings.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- 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 interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractActor
-
setType
public void setType(StringRangeCut.Type value)
Sets the type of cut operation to perform.- Parameters:
value
- the type
-
getType
public StringRangeCut.Type getType()
Returns the type of cut operation to perform.- Returns:
- the type
-
typeTipText
public String typeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRange
public void setRange(Range value)
Sets the range of characters/fields to extract.- Parameters:
value
- the range
-
getRange
public Range getRange()
Returns the range of characters/fields to extract.- Returns:
- the range
-
rangeTipText
public String rangeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setDelimiter
public void setDelimiter(String value)
Sets the delimiter to use.- Parameters:
value
- the delimiter
-
getDelimiter
public String getDelimiter()
Returns the delimiter in use.- Returns:
- the delimiter
-
delimiterTipText
public String delimiterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setGlue
public void setGlue(String value)
Sets the "glue" to use for joining the substrings.- Parameters:
value
- the glue
-
getGlue
public String getGlue()
Returns the "glue" to use for joining the substrings.- Returns:
- the glue
-
glueTipText
public String glueTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
process
protected String process(String s, int index)
Processes the string. If null is returned, this output will be ignored.- Specified by:
process
in classAbstractStringOperation
- Parameters:
s
- the string to processindex
- the 0-based index of the string currently being processed- Returns:
- the processed string or null if nothing produced
-
-