weka.gui.beans

## Class SubstringLabelerRules.SubstringLabelerMatchRule

- java.lang.Object
- - weka.gui.beans.SubstringLabelerRules.SubstringLabelerMatchRule

- All Implemented Interfaces:
    java.io.Serializable
  Enclosing class:
    SubstringLabelerRules

      public static class SubstringLabelerRules.SubstringLabelerMatchRule
      extends java.lang.Object
      implements java.io.Serializable

  Inner class encapsulating the logic for matching
  Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `MATCH_PART_SEPARATOR` Separator for parts of the match specification

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubstringLabelerRules.SubstringLabelerMatchRule()` Constructor
    `SubstringLabelerRules.SubstringLabelerMatchRule(java.lang.String setup)` Constructor
    `SubstringLabelerRules.SubstringLabelerMatchRule(java.lang.String match, boolean regex, boolean ignoreCase, java.lang.String selectedAtts)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `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` | `getLabel()` Get the label to assign if this rule matches, or empty string if binary flag attribute is being created.
    `java.lang.String` | `getMatch()` Get the string/regex to use for matching
    `boolean` | `getRegex()` Get whether this is a regular expression match or not
    `void` | `init(Environment env, Instances structure)` Initialize this match rule by substituting any environment variables in the attributes, match and label 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` | `setLabel(java.lang.String label)` Set the label to assign if this rule matches, or empty string if binary flag attribute is being created.
    `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
    `java.lang.String` | `toString()` Return a textual description of this match rule
    `java.lang.String` | `toStringInternal()` Get the internal representation of this rule

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MATCH_PART_SEPARATOR

          public static final java.lang.String MATCH_PART_SEPARATOR

      Separator for parts of the match specification
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SubstringLabelerRules.SubstringLabelerMatchRule

          public SubstringLabelerRules.SubstringLabelerMatchRule()

      Constructor

    - #### SubstringLabelerRules.SubstringLabelerMatchRule

          public SubstringLabelerRules.SubstringLabelerMatchRule(java.lang.String setup)

      Constructor
      Parameters:
        `setup` - an internally encoded representation of all the match information for this rule

    - #### SubstringLabelerRules.SubstringLabelerMatchRule

          public SubstringLabelerRules.SubstringLabelerMatchRule(java.lang.String match,
                                                         boolean regex,
                                                         boolean ignoreCase,
                                                         java.lang.String selectedAtts)

      Constructor
      Parameters:
        `match` - the match 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

    - #### setLabel

          public void setLabel(java.lang.String label)

      Set the label to assign if this rule matches, or empty string if binary flag attribute is being created.
      Parameters:
        `label` - the label string or empty string

    - #### getLabel

          public java.lang.String getLabel()

      Get the label to assign if this rule matches, or empty string if binary flag attribute is being created.
      Returns:
        the label string or empty 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 rule by substituting any environment variables in the attributes, match and label 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 java.lang.String apply(Instance inst)

      Apply this rule to the supplied instance
      Parameters:
        `inst` - the instance to apply to
      Returns:
        the label (or empty string) if this rule matches (empty string is used to indicate a match in the case that a binary flag attribute is being created), or null if the rule doesn't match.

    - #### toString

          public java.lang.String toString()

      Return a textual description of this match rule
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a textual description of this match rule

    - #### toStringInternal

          public java.lang.String toStringInternal()

      Get the internal representation of this rule
      Returns:
        a string formatted in the internal representation