org.speakright.core
Class ConfirmationWrapper
java.lang.Object
org.speakright.core.FlowBase
org.speakright.core.ConfirmationWrapper
- All Implemented Interfaces:
- java.io.Serializable, IConfirmationNotifier, IFlow
- Direct Known Subclasses:
- BaseSROQuestion.MyConfirmationWrapper
public class ConfirmationWrapper
- extends FlowBase
- implements IConfirmationNotifier
Implements confirmation in an extensible way. The class is a flow object
with two sub-flows: a question and a confirmer. The results from the
question are passed to the confirmer's needToExecute method. The confirmer
is run if it wants to. Then if the user rejects (says 'no') then the
question is asked again and the process repeats.
- Author:
- Ian Rae
- See Also:
- Serialized Form
| Methods inherited from class org.speakright.core.FlowBase |
createRenderer, execute, executionCount, fixupGrammar, fixupPrompt, getSubFlowAfter, log, logError, name, onBegin, onCatch, onComplete, onDisconnect, onEnd, onNoInput, onPlatformError, onTransferFailed, onValidateFailed, promptGroup, setExecutionCount, setName, setPromptGroup, shouldExecute, validateInput |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConfirmationWrapper
public ConfirmationWrapper(IFlow question,
IConfirmationFlow confirmer)
getFirst
public IFlow getFirst(IFlowContext context)
- start with the question.
- Specified by:
getFirst in interface IFlow- Overrides:
getFirst in class FlowBase
- Returns:
- an IFlow object to be executed.
doQuestionGetNext
public IFlow doQuestionGetNext(IFlow current,
SRResults results)
getNext
public IFlow getNext(IFlow current,
SRResults results)
- Apply the confirmation based on the state. In ASK state we activate the confirmer
if it wants execute. In CONFIRM_FINISHED state we switch back to ASK state if the user
rejected the confirmation.
Note. we don't track model vars and clear then during a rejection, because we're going
to run the question again. As long as you never this conf-wrapper before getting a good
answer (possibly confirmed), you're OK. Else model may hold a rejected value.
- Specified by:
getNext in interface IFlow- Overrides:
getNext in class FlowBase
- Parameters:
current - the currently executing flow object. More precisely, current is the flow
object that this object most recently returned from getFirst or getNext.results - the results of current's execution by the speech platform. Results
contains user input and/or events such as disconnect or platform-error.
- Returns:
- the next flow to run, or null which means this flow object is finished.
notifyConfirmationFinished
public void notifyConfirmationFinished(boolean wasRejected,
SRResults results)
- Callback from the confirmer. It has finished, and is about to be popped off the flow stack, and
the original question executed again. We need to restore the saved results before that
happens.
- Specified by:
notifyConfirmationFinished in interface IConfirmationNotifier
- Parameters:
wasRejected - whether the confirmation was rejected or notresults - the results object passed to getNext.