wyvern.lib.classes.filters
Class PigLatin

java.lang.Object
  extended bywyvern.lib.classes.filters.SpeechFilter
      extended bywyvern.lib.classes.filters.PigLatin
All Implemented Interfaces:
AddRemoveNotify, HookCallback, MethodHookCallback, MutableProperty

public class PigLatin
extends SpeechFilter
implements MethodHookCallback

A speech filter that makes people talk in Pig Latin.

Version:
1.0, Jul 09, 2002
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.lib.classes.filters.SpeechFilter
SpeechFilter.Replacement
 
Field Summary
 
Fields inherited from class wyvern.lib.classes.filters.SpeechFilter
agents_
 
Constructor Summary
PigLatin()
           
 
Method Summary
 java.lang.String applyFilter(java.lang.String text)
          Converts a string into paladin-speak.
 java.lang.String convertWord(java.lang.String word)
          Converts a word into pig-latin.
 java.lang.Object createClone()
          Produces a clone of the property for the caller.
 void detachFromAgent(Commandable agent)
          Stops filtering the specified agent.
 void filterAgent(Commandable agent)
          Attaches the filter to the specified agent.
 boolean isVowel(char c)
          Returns true if it's a vowel (not Y)
static void main(java.lang.String[] args)
          Tests the filter.
 void methodCalled(java.lang.String hookName, MethodHookable target, java.lang.Object data)
          Our "remove-curse" method was called.
static java.lang.String replace(java.lang.String s, java.lang.String old, java.lang.String rep)
          Replaces all occurrences of first string with second string.
 java.lang.String toString()
          Returns name of filter.
 
Methods inherited from class wyvern.lib.classes.filters.SpeechFilter
addGlobalPattern, addSinglePattern, filterSay, filterShout, filterTell, filterWhisper, getGlobalPatterns, getSinglePatterns, hookEvent, notifyAdd, notifyRemove, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PigLatin

public PigLatin()
Method Detail

applyFilter

public java.lang.String applyFilter(java.lang.String text)
Converts a string into paladin-speak.

Overrides:
applyFilter in class SpeechFilter
Parameters:
text - the initial text of the say/shout/tell
Returns:
the modified text

convertWord

public java.lang.String convertWord(java.lang.String word)
Converts a word into pig-latin.

Parameters:
word - a word

isVowel

public boolean isVowel(char c)
Returns true if it's a vowel (not Y)


replace

public static java.lang.String replace(java.lang.String s,
                                       java.lang.String old,
                                       java.lang.String rep)
Replaces all occurrences of first string with second string.


toString

public java.lang.String toString()
Returns name of filter.


createClone

public java.lang.Object createClone()
Produces a clone of the property for the caller. Required for MutableProperty interface.

Specified by:
createClone in interface MutableProperty

filterAgent

public void filterAgent(Commandable agent)
Attaches the filter to the specified agent. If you override this method, make sure it's synchronized.

Overrides:
filterAgent in class SpeechFilter

detachFromAgent

public void detachFromAgent(Commandable agent)
Description copied from class: SpeechFilter
Stops filtering the specified agent.

Overrides:
detachFromAgent in class SpeechFilter

methodCalled

public void methodCalled(java.lang.String hookName,
                         MethodHookable target,
                         java.lang.Object data)
Our "remove-curse" method was called.

Specified by:
methodCalled in interface MethodHookCallback
Parameters:
hookName - the name of the hook being run
target - the object on which the method was invoked: a GameMap or GameObject.
data - a method-specific data object; can be null. Check the documentation for the method hook to see if any data is passed to the callbacks.

main

public static void main(java.lang.String[] args)
Tests the filter.