summaryrefslogtreecommitdiff
path: root/NET/worlds/network/FilthyPhrase.java
blob: 4ad300d2dd64d3cfd7f58c3850fa2372a3f7dabc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*     */ 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)
/*     */   {
/*  25 */     this.rawData = new String(phrase);
/*  26 */     this.filthyWords = new Vector();
/*     */     
/*  28 */     StringTokenizer st = new StringTokenizer(phrase, 
/*  29 */       "\t\n\r.,;'\"!?*:/()[]{} ,「」『』《》?【】。!、;:", 
/*     */       
/*  31 */       true);
/*     */     
/*  33 */     if (st.hasMoreTokens()) {
/*  34 */       String firstToken = st.nextToken().toLowerCase();
/*  35 */       this.compareValue = firstToken.hashCode();
/*  36 */       this.filthyWords.addElement(firstToken);
/*     */     }
/*     */     
/*  39 */     while (st.hasMoreTokens()) {
/*  40 */       String nextWord = st.nextToken();
/*  41 */       this.filthyWords.addElement(nextWord.toLowerCase());
/*     */     }
/*     */   }
/*     */   
/*     */   public boolean check(String toCheck) {
/*  46 */     StringTokenizer st = new StringTokenizer(toCheck, 
/*  47 */       "\t\n\r.,;'\"!?*:/()[]{} ,「」『』《》?【】。!、;:", 
/*     */       
/*  49 */       true);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  54 */     int idx = 0;
/*  55 */     while (idx < this.filthyWords.size()) {
/*  56 */       if (st.hasMoreTokens()) {
/*  57 */         String token = st.nextToken().toLowerCase();
/*  58 */         String comparator = (String)this.filthyWords.elementAt(idx);
/*  59 */         if (comparator.compareTo(token) != 0) {
/*  60 */           return false;
/*     */         }
/*  62 */         idx++;
/*     */       } else {
/*  64 */         return false;
/*     */       }
/*     */     }
/*  67 */     return true;
/*     */   }
/*     */   
/*     */   public String getReplacement() {
/*  71 */     String funnyChars = new String("$!@%#@&*!%#@%!@#$%@#@!@%!@#$%*&%$!");
/*     */     
/*  73 */     String retVal = new String();
/*     */     
/*  75 */     int idx = 0;
/*  76 */     while (idx < this.filthyWords.size()) {
/*  77 */       int numChars = ((String)this.filthyWords.elementAt(idx)).length();
/*  78 */       String replacementWord = new String();
/*  79 */       if (numChars > 1) {
/*  80 */         replacementWord = funnyChars.substring(0, numChars);
/*     */       } else {
/*  82 */         replacementWord = (String)this.filthyWords.elementAt(idx);
/*     */       }
/*     */       
/*  85 */       retVal = retVal + replacementWord;
/*  86 */       idx++;
/*     */     }
/*     */     
/*  89 */     return retVal;
/*     */   }
/*     */   
/*     */   public long size() {
/*  93 */     return this.filthyWords.size();
/*     */   }
/*     */   
/*     */   public long compareValue() {
/*  97 */     return this.compareValue;
/*     */   }
/*     */   
/*     */   public String firstWord() {
/* 101 */     if (this.filthyWords.size() > 0) {
/* 102 */       return (String)this.filthyWords.elementAt(0);
/*     */     }
/* 104 */     return new String("");
/*     */   }
/*     */   
/*     */   public String asString()
/*     */   {
/* 109 */     return this.rawData;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\FilthyPhrase.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */