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
    • Field Detail

      • 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.
    • Constructor Detail

      • StringRangeCut

        public StringRangeCut()
    • Method Detail

      • 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.
      • 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