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:
@@ -192,12 +192,27 @@ public abstract class CurseFilter implements ChatFilter
|
|||||||
} else {
|
} else {
|
||||||
pattern += "|";
|
pattern += "|";
|
||||||
}
|
}
|
||||||
pattern += "\\b" + StringUtil.replace(st.nextToken(), "*", "[A-Za-z]*") + "\\b";
|
pattern += getStopWordRegexp(st.nextToken());
|
||||||
}
|
}
|
||||||
pattern += ")";
|
pattern += ")";
|
||||||
|
|
||||||
Pattern pat = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
|
setStopPattern(pattern);
|
||||||
_stopMatcher = pat.matcher("");
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user