avignon.handlers
Class MessagePicker

java.lang.Object
  extended byavignon.handlers.MessagePicker
All Implemented Interfaces:
java.io.FilenameFilter

public class MessagePicker
extends java.lang.Object
implements java.io.FilenameFilter

This class is used to pick a WAV file at random from a specified directory.


Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
           
 java.util.Random getGenerator()
          Allows the programmer to determine the random number generator being used.
static MessagePicker getInstance()
           
 java.lang.String getRandomMessage(java.lang.String path)
          If path matches the shunted path, this method will returned the shunted message.
 void setGenerator(java.util.Random value)
          Allows the programmer to set the random number generator being used to pick files at random.
 void shuntMessage(java.lang.String path, java.lang.String message)
          Sets the message that will be returned for a particular path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MessagePicker getInstance()

shuntMessage

public void shuntMessage(java.lang.String path,
                         java.lang.String message)
Sets the message that will be returned for a particular path. Only one shunted value is possible at a time. Usedfor unit testing.

Parameters:
path - The expected path to shunt.
message - The message that will be returned when a random message is requested for the given path.

getRandomMessage

public java.lang.String getRandomMessage(java.lang.String path)
If path matches the shunted path, this method will returned the shunted message. Otherwise it will return a WAV file at random picked from the specified path.

Parameters:
path - The path in which to search for WAV files.
Returns:
The full path to a WAV file n the given directory.

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Specified by:
accept in interface java.io.FilenameFilter

getGenerator

public java.util.Random getGenerator()
Allows the programmer to determine the random number generator being used.

Returns:
The java.math.Random being used to pick files.

setGenerator

public void setGenerator(java.util.Random value)
Allows the programmer to set the random number generator being used to pick files at random. This is used for unit testing purposes.

Parameters:
value - An instance of a java.math.Random to use for picking messages.

SourceForge.net Logo