CS 1705 Library

net.sf.webcat
Class StringNormalizer.RegexNormalizerRule

java.lang.Object
  extended by net.sf.webcat.StringNormalizer.RegexNormalizerRule
All Implemented Interfaces:
StringNormalizer.NormalizerRule
Enclosing class:
StringNormalizer

public static class StringNormalizer.RegexNormalizerRule
extends Object
implements StringNormalizer.NormalizerRule

A highly reusable concrete implementation of StringNormalizer.NormalizerRule that applies a series of regular expression substitutions.


Constructor Summary
StringNormalizer.RegexNormalizerRule(boolean everywhere, String... patterns)
          Create a new regular expression rule using a series of pattern/replacement pairs.
StringNormalizer.RegexNormalizerRule(String... patterns)
          Create a new regular expression rule using a series of pattern/replacement pairs.
 
Method Summary
 String normalize(String content)
          Normalize a string by applying all of this rule's regular expression pattern/replacement pairs, in order.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringNormalizer.RegexNormalizerRule

public StringNormalizer.RegexNormalizerRule(String... patterns)
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!)

StringNormalizer.RegexNormalizerRule

public StringNormalizer.RegexNormalizerRule(boolean everywhere,
                                            String... patterns)
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 Detail

normalize

public String normalize(String content)
Normalize a string by applying all of this rule's regular expression pattern/replacement pairs, in order.

Specified by:
normalize in interface StringNormalizer.NormalizerRule
Parameters:
content - The string to transform
Returns:
The result after all substitutions have been applied

Last updated: Wed, Apr 1, 2009 • 12:29 AM EDT

Copyright © 2009 Virginia Tech.