|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.crowd.chat.client.CurseFilter
public abstract class CurseFilter
A chat filter that can filter out curse words from user chat.
| Nested Class Summary | |
|---|---|
static class |
CurseFilter.Mode
Indicates how messages should be handled. |
| Field Summary | |
|---|---|
protected int[] |
_comicLength
Length of comic-y replacements for each curseword. |
protected Matcher[] |
_matchers
Matchers for each curseword. |
protected String[] |
_replacements
Replacements. |
protected Matcher |
_stopMatcher
A matcher that will always cause a message to be dropped if it matches. |
protected String[] |
_vernacular
Replacements for each curseword "in the vernacular". |
protected static String[] |
COMIC_CHARS
Comic replacement characters. |
| Constructor Summary | |
|---|---|
CurseFilter(String curseWords,
String stopWords)
Creates a curse filter. |
|
| Method Summary | |
|---|---|
protected String |
comicChars(int length)
Return a comicy replacement of the specified length. |
protected void |
configureCurseWords(String curseWords)
Configure the curse word portion of our filtering. |
protected void |
configureStopWords(String stopWords)
Configure the words that will stop. |
String |
filter(String msg,
Name otherUser,
boolean outgoing)
Filter a chat message. |
abstract CurseFilter.Mode |
getFilterMode()
The client will need to provide a way to look up our current chat filter mode. |
protected String |
getStopWordRegexp(String word)
Turns a naughty word into a regular expression to catch it. |
protected void |
setStopPattern(String pattern)
Sets our stop word matcher to one for the given regular expression. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Matcher _stopMatcher
protected Matcher[] _matchers
protected int[] _comicLength
protected String[] _replacements
protected String[] _vernacular
protected static final String[] COMIC_CHARS
| Constructor Detail |
|---|
public CurseFilter(String curseWords,
String stopWords)
*penis*=John_Thomas shit*=barnacle muff=britchesThe key/value pairs are separated by spaces, * matches word characters and the value after the = is the string into which to convert the text when converting to the vernacular. Underscores in the target string will be turned into spaces.
And stopWords should be in the following format:
*faggot* rape rapes raped rapingWords are separated by spaces and * matches any other word characters.
| Method Detail |
|---|
public abstract CurseFilter.Mode getFilterMode()
public String filter(String msg,
Name otherUser,
boolean outgoing)
ChatFilter
filter in interface ChatFiltermsg - the message text to be filtered.otherUser - an optional argument that represents the target or the speaker, depending
on 'outgoing', and can be considered in filtering if it is provided.outgoing - true if the message is going out to the server.
protected void configureCurseWords(String curseWords)
protected void configureStopWords(String stopWords)
protected void setStopPattern(String pattern)
protected String getStopWordRegexp(String word)
protected String comicChars(int length)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||