Class StringCut

  • 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 StringCut
    extends AbstractStringOperation
    Cuts out a part of a string. The cut can be either specified as a fixed character position or as a field from delimited columns.

    Input/output:
    - accepts:
       java.lang.String
       java.lang.String[]
    - generates:
       java.lang.String
       java.lang.String[]


    -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: StringCut
     
    -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 execution at this level gets stopped in case this
        actor encounters an error; the error gets propagated; useful for critical
        actors.
        default: false
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console; Note: the enclosing
        actor handler must have this enabled as well.
        default: false
     
    -type <FIELD_DELIMITED|CHARACTER_POSITIONS> (property: type)
        Determines what type of cut to perform.
        default: FIELD_DELIMITED
     
    -field-delimiter <java.lang.String> (property: fieldDelimiter)
        The field delimiter to use; \t gets automatically converted into its character
        counterpart.
        default: \\t
     
    -field-index <adams.core.Index> (property: fieldIndex)
        The 1-based index of the field to cut from the string(s).
        default: 1
        example: An index is a number starting with 1; the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -char-start-pos <adams.core.Index> (property: characterStartPos)
        The position of the first character to include in case fixed character positions
        are used.
        default: first
        example: An index is a number starting with 1; the following placeholders can be used as well: first, second, third, last_2, last_1, last
     
    -char-end-pos <adams.core.Index> (property: characterEndPos)
        The position of the last character to include in case fixed character positions
        are used.
        default: last
        example: An index is a number starting with 1; 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

      • m_CharacterStartPos

        protected Index m_CharacterStartPos
        the character starting position.
      • m_CharacterEndPos

        protected Index m_CharacterEndPos
        the character end position.
      • m_FieldDelimiter

        protected String m_FieldDelimiter
        the field delimiter.
      • m_FieldIndex

        protected Index m_FieldIndex
        the field number to extract.
    • Constructor Detail

      • StringCut

        public StringCut()
    • Method Detail

      • setType

        public void setType​(StringCut.CutType value)
        Sets the type of cut to perform.
        Parameters:
        value - the type of cut
      • getType

        public StringCut.CutType getType()
        Returns the type of cut to perform.
        Returns:
        the type of cut
      • 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.
      • setCharacterStartPos

        public void setCharacterStartPos​(Index value)
        Sets the position of the first character to include.
        Parameters:
        value - the starting position
      • getCharacterStartPos

        public Index getCharacterStartPos()
        Returns the position of the first character to include.
        Returns:
        the starting position
      • characterStartPosTipText

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

        public void setCharacterEndPos​(Index value)
        Sets the position of the last character to include.
        Parameters:
        value - the end position
      • getCharacterEndPos

        public Index getCharacterEndPos()
        Returns the position of the last character to include.
        Returns:
        the end position
      • characterEndPosTipText

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

        public void setFieldDelimiter​(String value)
        Sets the field delimiter to use.
        Parameters:
        value - the delimiter
      • getFieldDelimiter

        public String getFieldDelimiter()
        Returns the field delimiter in use.
        Returns:
        the delimiter
      • fieldDelimiterTipText

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

        public void setFieldIndex​(Index value)
        Sets the index of the field to cut.
        Parameters:
        value - the index
      • getFieldIndex

        public Index getFieldIndex()
        Returns the index of the field to cut.
        Returns:
        the index
      • fieldIndexTipText

        public String fieldIndexTipText()
        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,
                                 int index)
        Processes the string. If null is returned, this output will be ignored.
        Specified by:
        process in class AbstractStringOperation
        Parameters:
        s - the string to process
        index - the 0-based index of the string currently being processed
        Returns:
        the processed string or null if nothing produced