Break a few parts out for use in subclasses

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5821 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Dave Hoover
2009-06-09 21:00:21 +00:00
parent c3845a8b15
commit c016fab8e8
@@ -192,12 +192,27 @@ public abstract class CurseFilter implements ChatFilter
} else {
pattern += "|";
}
pattern += "\\b" + StringUtil.replace(st.nextToken(), "*", "[A-Za-z]*") + "\\b";
pattern += getStopWordRegexp(st.nextToken());
}
pattern += ")";
Pattern pat = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
_stopMatcher = pat.matcher("");
setStopPattern(pattern);
}
/**
* Sets our stop word matcher to one for the given regular expression.
*/
protected void setStopPattern (String pattern)
{
_stopMatcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher("");
}
/**
* Turns a naughty word into a regular expression to catch it.
*/
protected String getStopWordRegexp (String word)
{
return "\\b" + StringUtil.replace(word, "*", "[A-Za-z]*") + "\\b";
}
/**