1 53 54 106 107 package com.Yasna.forum.filter; 108 109 import java.util.*; 110 import java.io.*; 111 112 import com.Yasna.forum.*; 113 import com.Yasna.codeviewer.*; 114 115 118 public class FilterHackerSpeak extends ForumMessageFilter implements Serializable { 119 120 123 private Properties props; 124 125 128 private Properties propDescriptions; 129 130 135 public FilterHackerSpeak() { 136 super(); 137 props = new Properties(); 138 propDescriptions = new Properties(); 139 } 140 141 149 public FilterHackerSpeak(ForumMessage message, Properties props, 150 Properties propDescriptions) 151 { 152 super(message); 153 this.props = new Properties(props); 154 this.propDescriptions = new Properties(propDescriptions); 155 } 156 157 163 public ForumMessageFilter clone(ForumMessage message){ 164 return new FilterHackerSpeak(message,props,propDescriptions); 165 } 166 167 170 public String getName() { 171 return "Hacker Speak"; 172 } 173 174 177 public String getDescription() { 178 return "Translates normal text into 'Hacker Speak'."; 179 } 180 181 184 public String getAuthor() { 185 return "CoolServlets.com"; 186 } 187 188 191 public int getMajorVersion() { 192 return 1; 193 } 194 195 198 public int getMinorVersion() { 199 return 0; 200 } 201 202 208 public String getFilterProperty(String name) { 209 return props.getProperty(name); 210 } 211 212 218 public String getFilterPropertyDescription(String name) { 219 return propDescriptions.getProperty(name); 220 } 221 222 225 public Enumeration filterPropertyNames() { 226 return null; 228 } 229 230 240 public void setFilterProperty(String name, String value) 241 throws IllegalArgumentException 242 { 243 if (props.getProperty(name) == null) { 244 throw new IllegalArgumentException (); 245 } 246 props.put(name, value); 247 } 248 249 253 public String getSubject() { 254 return makeHacker(message.getSubject()); 255 } 256 257 261 public String getBody() { 262 return makeHacker(message.getBody()); 263 } 264 265 274 private String makeHacker( String input ) { 275 if( input == null || input.length() == 0 ) { 278 return input; 279 } 280 StringBuffer buf = new StringBuffer (input.length()); 283 char ch = ' '; 284 for( int i=0; i<input.length(); i++ ) { 285 ch = input.charAt(i); 286 if (Math.random() < .20) { 287 if( ch == 'a' ) { 288 buf.append( "@" ); 289 } 290 else if( ch == 'e' ) { 291 buf.append( "3" ); 292 } 293 else if( ch == 'g' ) { 294 buf.append( "6" ); 295 } 296 else if( ch == 'i' ) { 297 buf.append( "1" ); 298 } 299 else if( ch == 'o' ) { 300 buf.append( "0" ); 301 } 302 else if( ch == 't' ) { 303 buf.append( "7" ); 304 } 305 else if( ch == 's' ) { 306 buf.append( "$" ); 307 } 308 else { 309 buf.append( ch ); 310 } 311 } 312 else { 313 buf.append( ch ); 314 } 315 } 316 return buf.toString(); 317 } 318 } 319 | Popular Tags |