Package weka.gui.beans
Class SubstringReplacerRules.SubstringReplacerMatchRule
java.lang.Object
weka.gui.beans.SubstringReplacerRules.SubstringReplacerMatchRule
- All Implemented Interfaces:
Serializable
- Enclosing class:
- SubstringReplacerRules
public static class SubstringReplacerRules.SubstringReplacerMatchRule
extends Object
implements Serializable
Inner class encapsulating the logic for matching and replacing.
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructorSubstringReplacerMatchRule
(String setup) ConstructorSubstringReplacerMatchRule
(String match, String replace, boolean regex, boolean ignoreCase, String selectedAtts) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply this rule to the supplied array of strings.void
Apply this rule to the supplied instanceGet the attributes to apply the rule toboolean
Get whether to ignore case when matchinggetMatch()
Get the string/regex to use for matchingboolean
getRegex()
Get whether this is a regular expression match or notGet the replace stringvoid
init
(Environment env, Instances structure) Initialize this match replace rule by substituting any environment variables in the attributes, match and replace strings.void
Set the attributes to apply the rule tovoid
setIgnoreCase
(boolean ignore) Set whether to ignore case when matchingvoid
Set the string/regex to use for matchingvoid
setRegex
(boolean regex) Set whether this is a regular expression match or notvoid
setReplace
(String replace) Set the replace stringtoString()
Return a textual description of this ruleReturn the internally encoded representation of this rule
-
Constructor Details
-
SubstringReplacerMatchRule
public SubstringReplacerMatchRule()Constructor -
SubstringReplacerMatchRule
Constructor- Parameters:
setup
- an internally encoded representation of all the match and replace information for this rule
-
SubstringReplacerMatchRule
public SubstringReplacerMatchRule(String match, String replace, boolean regex, boolean ignoreCase, String selectedAtts) Constructor- Parameters:
match
- the match stringreplace
- the replace stringregex
- true if this is a regular expression matchignoreCase
- true if case is to be ignoredselectedAtts
- the attributes to apply the rule to
-
-
Method Details
-
setMatch
Set the string/regex to use for matching- Parameters:
match
- the match string
-
getMatch
Get the string/regex to use for matching- Returns:
- the match string
-
setReplace
Set the replace string- Parameters:
replace
- the replace 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
Set the attributes to apply the rule to- Parameters:
a
- the attributes to apply the rule to.
-
getAttsToApplyTo
Get the attributes to apply the rule to- Returns:
- the attributes to apply the rule to.
-
init
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 variablesstructure
- the structure of the incoming instances
-
apply
Apply this rule to the supplied instance- Parameters:
inst
- the instance to apply to
-
apply
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
Return a textual description of this rule -
toStringInternal
Return the internally encoded representation of this rule- Returns:
- the internally (parseable) representation of this rule
-