Package student.testingsupport
Class StringNormalizer.RegexNormalizerRule
java.lang.Object
student.testingsupport.StringNormalizer.NormalizerRule
student.testingsupport.StringNormalizer.RegexNormalizerRule
- Direct Known Subclasses:
NormalizerRuleIgnoreLeadingNewlines
,NormalizerRuleTrailingColonPerLine
,NormalizerRuleTrailingSpacePerLine
- Enclosing class:
- StringNormalizer
A highly reusable concrete implementation of
StringNormalizer.NormalizerRule
that applies a series of regular expression
substitutions.-
Constructor Summary
ConstructorsConstructorDescriptionRegexNormalizerRule
(String displayName, boolean everywhere, String... patterns) Create a new regular expression rule using a series of pattern/replacement pairs.RegexNormalizerRule
(String displayName, String... patterns) Create a new regular expression rule using a series of pattern/replacement pairs. -
Method Summary
-
Constructor Details
-
RegexNormalizerRule
Create a new regular expression rule using a series of pattern/replacement pairs. Each pattern/replacement will be applied globally (all matches that can be found). If multiple patterns are given, they will be applied in the order given. Use this form:myRule = new RegexNormalizerRule( "pattern1", "replacement1", "pattern2", "replacement2", ... // As many as you want );
- Parameters:
patterns
- a series of regular expression pattern/replacement pairs (there must be an even number!)
-
RegexNormalizerRule
Create a new regular expression rule using a series of pattern/replacement pairs.- Parameters:
everywhere
- True if all pattern/replacements should be applied globally (for every match), or false if the replacements should only be applied to the first match for each pattern.patterns
- a series of regular expression pattern/replacement pairs (there must be an even number!)
-
-
Method Details
-
hashCode
public int hashCode()- Specified by:
hashCode
in classStringNormalizer.NormalizerRule
-
equals
- Specified by:
equals
in classStringNormalizer.NormalizerRule
-
normalize
Normalize a string by applying all of this rule's regular expression pattern/replacement pairs, in order.- Specified by:
normalize
in classStringNormalizer.NormalizerRule
- Parameters:
content
- The string to transform- Returns:
- The result after all substitutions have been applied
-
displayName
Description copied from class:StringNormalizer.NormalizerRule
Human readable name of the rule- Specified by:
displayName
in classStringNormalizer.NormalizerRule
- Returns:
- The name
-