public class TextSynthesizer.OutputHandler extends Thread
TextSynthesizer
. Sends
all text to standard out.Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected static int |
CANCEL |
protected static int |
CANCEL_ALL |
protected static int |
CANCEL_COMPLETE |
protected int |
command
For the item at the top of the queue, the output command reflects
whether item should be PAUSE, RESUME, CANCEL.
|
protected Object |
commandLock
Object on which accesses to the command must synchronize.
|
(package private) TextSynthesizerQueueItem |
currentItem
The current item to speak.
|
protected Object |
currentItemLock
Object to lock on for setting the current item.
|
protected boolean |
done |
protected static int |
PAUSE |
protected Vector |
queue
Internal speech output queue that will contain a set of
TextSynthesizerQueueItems.
|
(package private) int |
rate
Current output "speaking" rate.
|
protected static int |
RESUME |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
OutputHandler()
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
appendQueue(TextSynthesizerQueueItem item)
Adds an item to be spoken to the output queue.
|
protected void |
cancelAllItems()
Cancels all items.
|
protected void |
cancelItem()
Cancels the current item.
|
protected void |
cancelItem(int cancelType)
Cancels all or just the current item.
|
protected void |
cancelItem(Object source)
Cancels the given item.
|
Enumeration |
enumerateQueue()
Returns the current queue.
|
protected TextSynthesizerQueueItem |
getQueueItem()
Returns, but does not remove, the first item on the queue.
|
protected boolean |
isCommand(String engineText,
int index)
Determines if the next thing in line is a command.
|
boolean |
isQueueEmpty()
Determines if the queue is empty.
|
protected boolean |
isWhitespace(String engineText,
int index)
Determines if there is whitespace at the current index.
|
protected int |
outputItem(TextSynthesizerQueueItem item)
Starts outputting the item.
|
protected void |
pauseItem()
Pauses the output.
|
protected int |
processCommand(TextSynthesizerQueueItem item,
String engineText,
int index)
Attempts to process a command starting at the next character
in the synthesizer text.
|
protected int |
processNormalText(TextSynthesizerQueueItem item,
String engineText,
int index)
Processes next set of characters in output up to whitespace
or next '/' that could indicate the start of a command.
|
protected int |
processWhitespace(String engineText,
int index)
Processes whitespace at the current index in the synthesizer text.
|
protected void |
resumeItem()
Resumes the output.
|
void |
run()
Controls output of text until terminate is called.
|
void |
terminate()
Stops execution of the Thread.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected boolean done
protected Vector queue
BaseSynthesizerQueueItem
TextSynthesizerQueueItem currentItem
protected Object currentItemLock
int rate
protected int command
protected static final int PAUSE
protected static final int RESUME
protected static final int CANCEL
protected static final int CANCEL_ALL
protected static final int CANCEL_COMPLETE
protected Object commandLock
public OutputHandler()
public void terminate()
public Enumeration enumerateQueue()
public boolean isQueueEmpty()
true
if the queue is emptypublic void appendQueue(TextSynthesizerQueueItem item)
item
- the item to be addedprotected void cancelItem()
protected void cancelAllItems()
protected void cancelItem(int cancelType)
cancelType
- CANCEL
or CANCEL_ALL
protected void cancelItem(Object source)
source
- the item to cancelprotected void pauseItem()
protected void resumeItem()
public void run()
run
in interface Runnable
run
in class Thread
terminate()
protected TextSynthesizerQueueItem getQueueItem()
protected int outputItem(TextSynthesizerQueueItem item)
item
- to be outputprotected boolean isCommand(String engineText, int index)
engineText
- the text containing embedded commandsindex
- the current indextrue
if the next thing in line is a commandprotected int processCommand(TextSynthesizerQueueItem item, String engineText, int index)
item
- the current queue itemengineText
- the text containing embedded commandsindex
- the current indexprotected boolean isWhitespace(String engineText, int index)
engineText
- the text containing embedded commandsindex
- the current indextrue
if there is whitespace at the
current indexprotected int processWhitespace(String engineText, int index)
engineText
- the text containing embedded commandsindex
- the current indexprotected int processNormalText(TextSynthesizerQueueItem item, String engineText, int index)
item
- the current queue itemengineText
- the text containing embedded commandsindex
- the current indexWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses