org.speakright.core.flows
Class BasicFlow

java.lang.Object
  extended by org.speakright.core.FlowBase
      extended by org.speakright.core.flows.BasicFlow
All Implemented Interfaces:
java.io.Serializable, IFlow
Direct Known Subclasses:
App1, AppWithLoop, AsyncFlow, ChoiceFlow, Flow2Wrapper, FlowList, LoopFlow, MyFlow, SRApp, ValFlow

public class BasicFlow
extends FlowBase

BasicFlow is a base class for most flow objects. It supports sub-flows which you add using the add method. Sub-flows can be optional; if their shouldExeucte returns false, they are skipped and the next sub-flow is run. It's an error if all the sub-flows return false from their shouldExecute method.

Author:
IanRaeLaptop
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList<IFlow> m_L
           
 
Constructor Summary
BasicFlow()
           
 
Method Summary
 void add(IFlow flow)
          add a sub-flow.
 void addPromptFlow(java.lang.String ptext)
          Adds a prompt flow object.
protected  int findSubFlow(IFlow subFlow)
          Get the index of subFlow, if its one of our sub-flows
 IFlow getFirst(IFlowContext context)
          If there are sub-flows then return the first one, otherwise return self.
 IFlow getNext(IFlow current, SRResults results)
          get the next flow.
 IFlow getSubFlowAfter(IFlow subFlow)
          Return the next sub-flow after subFlow.
 int SubFlowCount()
          get the number of sub-flows of this flow.
 
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
 

Field Detail

m_L

protected java.util.ArrayList<IFlow> m_L
Constructor Detail

BasicFlow

public BasicFlow()
Method Detail

SubFlowCount

public int SubFlowCount()
get the number of sub-flows of this flow.


add

public void add(IFlow flow)
add a sub-flow. Sub-flows will be executed in the order they were added.

Parameters:
flow -

addPromptFlow

public void addPromptFlow(java.lang.String ptext)
Adds a prompt flow object. Equivalent to add(new PromptFlow("some text"))

Parameters:
ptext - prompt text

getFirst

public IFlow getFirst(IFlowContext context)
If there are sub-flows then return the first one, otherwise return self. BasicFlow supports optional sub-flows. An optional sub-flow can return null from it's getFirst method to indicate that it doesn't wish to run. BasicFlow must still adhere to the rule that SRRunner requires getFirst never return null; therefore at least one sub-flow's getFirst must return non-null. Detail: getFirst method of sub-flows may be called more than once.

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

getSubFlowAfter

public IFlow getSubFlowAfter(IFlow subFlow)
Description copied from interface: IFlow
Return the next sub-flow after subFlow. Return null if subFlow is not one of our sub-flows, or there is no next one after it. This method is used to implement optional sub-flows (see BasicFlow)

Specified by:
getSubFlowAfter in interface IFlow
Overrides:
getSubFlowAfter in class FlowBase
Returns:
null or next sub-flow after subFlow

findSubFlow

protected int findSubFlow(IFlow subFlow)
Get the index of subFlow, if its one of our sub-flows

Parameters:
subFlow - a possible sub-flow object.
Returns:
-1 if not one of our sub-flows, otherwise it's index

getNext

public IFlow getNext(IFlow current,
                     SRResults results)
get the next flow. If there are sub-flows then return the next sub-flow.

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.