summaryrefslogtreecommitdiff
path: root/NET/worlds/network/FilthyPhrase.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/network/FilthyPhrase.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/network/FilthyPhrase.java')
-rw-r--r--NET/worlds/network/FilthyPhrase.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/NET/worlds/network/FilthyPhrase.java b/NET/worlds/network/FilthyPhrase.java
new file mode 100644
index 0000000..17c0d01
--- /dev/null
+++ b/NET/worlds/network/FilthyPhrase.java
@@ -0,0 +1,80 @@
+package NET.worlds.network;
+
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+public class FilthyPhrase {
+ private long compareValue;
+ private Vector<String> filthyWords;
+ private String rawData;
+
+ public FilthyPhrase(String phrase) {
+ this.rawData = new String(phrase);
+ this.filthyWords = new Vector<String>();
+ StringTokenizer st = new StringTokenizer(phrase, "\t\n\r.,;'\"!?*:/()[]{} ,「」『』《》?【】。!、;:", true);
+ if (st.hasMoreTokens()) {
+ String firstToken = st.nextToken().toLowerCase();
+ this.compareValue = firstToken.hashCode();
+ this.filthyWords.addElement(firstToken);
+ }
+
+ while (st.hasMoreTokens()) {
+ String nextWord = st.nextToken();
+ this.filthyWords.addElement(nextWord.toLowerCase());
+ }
+ }
+
+ public boolean check(String toCheck) {
+ StringTokenizer st = new StringTokenizer(toCheck, "\t\n\r.,;'\"!?*:/()[]{} ,「」『』《》?【】。!、;:", true);
+
+ for (int idx = 0; idx < this.filthyWords.size(); idx++) {
+ if (!st.hasMoreTokens()) {
+ return false;
+ }
+
+ String token = st.nextToken().toLowerCase();
+ String comparator = this.filthyWords.elementAt(idx);
+ if (comparator.compareTo(token) != 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public String getReplacement() {
+ String funnyChars = new String("$!@%#@&*!%#@%!@#$%@#@!@%!@#$%*&%$!");
+ String retVal = new String();
+
+ for (int idx = 0; idx < this.filthyWords.size(); idx++) {
+ int numChars = this.filthyWords.elementAt(idx).length();
+ new String();
+ String replacementWord;
+ if (numChars > 1) {
+ replacementWord = funnyChars.substring(0, numChars);
+ } else {
+ replacementWord = this.filthyWords.elementAt(idx);
+ }
+
+ retVal = retVal + replacementWord;
+ }
+
+ return retVal;
+ }
+
+ public long size() {
+ return this.filthyWords.size();
+ }
+
+ public long compareValue() {
+ return this.compareValue;
+ }
+
+ public String firstWord() {
+ return this.filthyWords.size() > 0 ? this.filthyWords.elementAt(0) : new String("");
+ }
+
+ public String asString() {
+ return this.rawData;
+ }
+}