Class SubstringReplacerRules.SubstringReplacerMatchRule

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    SubstringReplacerRules

    public static class SubstringReplacerRules.SubstringReplacerMatchRule
    extends java.lang.Object
    implements java.io.Serializable
    Inner class encapsulating the logic for matching and replacing.
    Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(java.lang.String[] stringVals)
      Apply this rule to the supplied array of strings.
      void apply​(Instance inst)
      Apply this rule to the supplied instance
      java.lang.String getAttsToApplyTo()
      Get the attributes to apply the rule to
      boolean getIgnoreCase()
      Get whether to ignore case when matching
      java.lang.String getMatch()
      Get the string/regex to use for matching
      boolean getRegex()
      Get whether this is a regular expression match or not
      java.lang.String getReplace()
      Get the replace string
      void init​(Environment env, Instances structure)
      Initialize this match replace rule by substituting any environment variables in the attributes, match and replace strings.
      void setAttsToApplyTo​(java.lang.String a)
      Set the attributes to apply the rule to
      void setIgnoreCase​(boolean ignore)
      Set whether to ignore case when matching
      void setMatch​(java.lang.String match)
      Set the string/regex to use for matching
      void setRegex​(boolean regex)
      Set whether this is a regular expression match or not
      void setReplace​(java.lang.String replace)
      Set the replace string
      java.lang.String toString()
      Return a textual description of this rule
      java.lang.String toStringInternal()
      Return the internally encoded representation of this rule
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SubstringReplacerMatchRule

        public SubstringReplacerMatchRule()
        Constructor
      • SubstringReplacerMatchRule

        public SubstringReplacerMatchRule​(java.lang.String setup)
        Constructor
        Parameters:
        setup - an internally encoded representation of all the match and replace information for this rule
      • SubstringReplacerMatchRule

        public SubstringReplacerMatchRule​(java.lang.String match,
                                          java.lang.String replace,
                                          boolean regex,
                                          boolean ignoreCase,
                                          java.lang.String selectedAtts)
        Constructor
        Parameters:
        match - the match string
        replace - the replace string
        regex - true if this is a regular expression match
        ignoreCase - true if case is to be ignored
        selectedAtts - the attributes to apply the rule to
    • Method Detail

      • setMatch

        public void setMatch​(java.lang.String match)
        Set the string/regex to use for matching
        Parameters:
        match - the match string
      • getMatch

        public java.lang.String getMatch()
        Get the string/regex to use for matching
        Returns:
        the match string
      • setReplace

        public void setReplace​(java.lang.String replace)
        Set the replace string
        Parameters:
        replace - the replace string
      • getReplace

        public java.lang.String getReplace()
        Get the replace string
        Returns:
        the replace string
      • setRegex

        public void setRegex​(boolean regex)
        Set whether this is a regular expression match or not
        Parameters:
        regex - true if this is a regular expression match
      • getRegex

        public boolean getRegex()
        Get whether this is a regular expression match or not
        Returns:
        true if this is a regular expression match
      • setIgnoreCase

        public void setIgnoreCase​(boolean ignore)
        Set whether to ignore case when matching
        Parameters:
        ignore - true if case is to be ignored
      • getIgnoreCase

        public boolean getIgnoreCase()
        Get whether to ignore case when matching
        Returns:
        true if case is to be ignored
      • setAttsToApplyTo

        public void setAttsToApplyTo​(java.lang.String a)
        Set the attributes to apply the rule to
        Parameters:
        a - the attributes to apply the rule to.
      • getAttsToApplyTo

        public java.lang.String getAttsToApplyTo()
        Get the attributes to apply the rule to
        Returns:
        the attributes to apply the rule to.
      • init

        public void init​(Environment env,
                         Instances structure)
        Initialize this match replace rule by substituting any environment variables in the attributes, match and replace strings. Sets up the attribute indices to apply to and validates that the selected attributes are all String attributes
        Parameters:
        env - the environment variables
        structure - the structure of the incoming instances
      • apply

        public void apply​(Instance inst)
        Apply this rule to the supplied instance
        Parameters:
        inst - the instance to apply to
      • apply

        public void apply​(java.lang.String[] stringVals)
        Apply this rule to the supplied array of strings. This array is expected to contain string values from an instance at the same index that they occur in the original instance. Null elements indicate non-string or missing values from the original instance
        Parameters:
        stringVals - an array of strings containing string values from an input instance
      • toString

        public java.lang.String toString()
        Return a textual description of this rule
        Overrides:
        toString in class java.lang.Object
        Returns:
        textual description of this rule
      • toStringInternal

        public java.lang.String toStringInternal()
        Return the internally encoded representation of this rule
        Returns:
        the internally (parseable) representation of this rule