org.speakright.core.flows
Class ChoiceFlow

java.lang.Object
  extended by org.speakright.core.FlowBase
      extended by org.speakright.core.flows.BasicFlow
          extended by org.speakright.core.flows.ChoiceFlow
All Implemented Interfaces:
java.io.Serializable, IFlow
Direct Known Subclasses:
App.MainMenu, MyMenu

public class ChoiceFlow
extends BasicFlow

ChoiceFlow provides branching based on user input, such as in a menu. ChoiceFlow contains a menu question, and some choices. Each choice is a user input string and the IFlow to execute when that user input occurs.

Author:
Ian Rae
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.speakright.core.flows.BasicFlow
m_L
 
Constructor Summary
ChoiceFlow(java.lang.String name)
           
 
Method Summary
 void addChoice(java.lang.String choice, IFlow flow)
          Adds a choice.
 IFlow getFirst(IFlowContext context)
          Returns the choice question.
 IFlow getNext(IFlow current, SRResults results)
          Returns the flow for the choice that matches the user input.
protected  void setChoiceQuestion(IFlow flow)
          Sets the flow object that will ask the choice question.
 
Methods inherited from class org.speakright.core.flows.BasicFlow
add, addPromptFlow, findSubFlow, getSubFlowAfter, SubFlowCount
 
Methods inherited from class org.speakright.core.FlowBase
createRenderer, execute, executionCount, fixupGrammar, fixupPrompt, 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
 

Constructor Detail

ChoiceFlow

public ChoiceFlow(java.lang.String name)
Method Detail

setChoiceQuestion

protected void setChoiceQuestion(IFlow flow)
Sets the flow object that will ask the choice question. This MUST be called before this flow object is executed.

Parameters:
flow - the flow object that will ask the choice question.

addChoice

public void addChoice(java.lang.String choice,
                      IFlow flow)
Adds a choice.

Parameters:
choice - the user input string for this choice.
flow - IFlow to be executed when the user input equals choice

getFirst

public IFlow getFirst(IFlowContext context)
Returns the choice question.

Specified by:
getFirst in interface IFlow
Overrides:
getFirst in class BasicFlow
Returns:
an IFlow object to be executed.

getNext

public IFlow getNext(IFlow current,
                     SRResults results)
Returns the flow for the choice that matches the user input.

Specified by:
getNext in interface IFlow
Overrides:
getNext in class BasicFlow
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.