|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.speakright.core.FlowBase
public class FlowBase
FlowBase is an adapter for IFlow; it implements all the IFlow interface methods. Most flow objects derive from FlowBase so that they need only to override a few of the IFlow methods.
The default behaviour that FlowBase implements is a do-nothing flow object with no sub-flows. It returns itself in getFirst, and null in getNext, and execute does nothing.
| Constructor Summary | |
|---|---|
FlowBase()
|
|
FlowBase(java.lang.String name)
Create a flow with the given name. |
|
| Method Summary | |
|---|---|
IFlowRenderer |
createRenderer()
|
void |
execute(IExecutionContext context)
The default implementation of execute is to render this object. |
int |
executionCount()
The number of times this flow has been executed (in the current activation). |
Grammar |
fixupGrammar(Grammar gram)
The default implementation is to do nothing. |
java.lang.String |
fixupPrompt(java.lang.String item)
The default implementation is to do nothing. |
IFlow |
getFirst(IFlowContext context)
The default implementation of getFirst is to return this. |
IFlow |
getNext(IFlow current,
SRResults results)
The default implementation of getNext is to return null. |
IFlow |
getSubFlowAfter(IFlow subFlow)
Return the next sub-flow after subFlow. |
void |
log(java.lang.String message)
Log to the SpeakRight logger (log4j) |
void |
logError(java.lang.String message)
Log an error to the SpeakRight logger (log4j). |
java.lang.String |
name()
Name of the flow object, used for logging and (optionally) as a means of finding flow objects. |
void |
onBegin(IFlowContext context)
The default implementation of onBegin is to do nothing. |
IFlow |
onCatch(IFlow current,
SRResults results,
java.lang.String eventName,
ThrowEvent event)
The default implementation of onCatch is to return null, indicating that this object does not handle custom events. |
boolean |
onComplete()
The default implementation is to return true; |
IFlow |
onDisconnect(IFlow current,
SRResults results)
The default implementation of onDisconnect is to return null, indicating that this object does not handle disconnect events. |
void |
onEnd(IFlowContext context)
The default implementation of onEnd is to do nothing. |
IFlow |
onNoInput(IFlow current,
SRResults results)
The default implementation of onNoInput is to return null, indicating that this object does not handle no-input events. |
IFlow |
onPlatformError(IFlow current,
SRResults results)
The default implementation of onCatch is to return null, indicating that this object does not handle platform errors. |
IFlow |
onTransferFailed(IFlow current,
SRResults results)
The default implementation of onCatch is to return null, indicating that this object does not handle transfer failures. |
IFlow |
onValidateFailed(IFlow current,
SRResults results)
The default implementation of onValidateFailed is to return null, indicating that this object does not handle validate-failed events. |
java.lang.String |
promptGroup()
The prompt group prefix applies to prompt ids. |
void |
setExecutionCount(int count)
Used internally by SRInstance. |
void |
setName(java.lang.String name)
Sets the name of the flow object. |
void |
setPromptGroup(java.lang.String groupPrefix)
Set the prompt group prefix. |
boolean |
shouldExecute()
Used for optional sub-flows. |
boolean |
validateInput(java.lang.String input,
SRResults results)
The default implementation is to return true. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FlowBase()
public FlowBase(java.lang.String name)
name - | Method Detail |
|---|
public java.lang.String name()
IFlowName should be a descriptive single word, such as "AskFlightNumber". Question flows should begin with a verb such as "Ask", and output flows should begin with a verb such as "Say".
If the name is not specified by the developer, a flow's default name is the class name, for example, org.foobar.flightapp.AskFlightNumber. Names do not need to be unique.
name in interface IFlowpublic void log(java.lang.String message)
message - public void logError(java.lang.String message)
message - public void setName(java.lang.String name)
name - IFlow.name()public void execute(IExecutionContext context)
execute in interface IFlowcontext - Contains the page renderer.public IFlow getFirst(IFlowContext context)
getFirst in interface IFlow
public IFlow getNext(IFlow current,
SRResults results)
getNext in interface IFlowcurrent - 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.
public void onBegin(IFlowContext context)
onBegin in interface IFlowpublic void onEnd(IFlowContext context)
onEnd in interface IFlow
public IFlow onDisconnect(IFlow current,
SRResults results)
onDisconnect in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution. In this case results will
contain a Disconnect result code. User input may be present, if the caller spoke before hanging
up. Some applications may want to process this final utterance before terminating.
public IFlow onNoInput(IFlow current,
SRResults results)
onNoInput in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution. In this case results will
contain a Disconnect result code. User input may be present, if the caller spoke before hanging
up. Some applications may want to process this final utterance before terminating.
public IFlow onCatch(IFlow current,
SRResults results,
java.lang.String eventName,
ThrowEvent event)
onCatch in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution.eventName - name of the event. most event handling can be done using just the name.event - event object. advanced event handling may require the actual event object
public IFlow onPlatformError(IFlow current,
SRResults results)
onPlatformError in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution. In this case results will
contain a PlatformFailed result code.
public IFlow onTransferFailed(IFlow current,
SRResults results)
onTransferFailed in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution. In this case results will
contain a TransferFailed result code.
public IFlow onValidateFailed(IFlow current,
SRResults results)
onValidateFailed in interface IFlowcurrent - the currently executing flow object.results - the results of current's execution. In this case results will
contain the user input that failed validation.
public boolean validateInput(java.lang.String input,
SRResults results)
validateInput in interface IFlowinput - String value of the user input. For simple, single-value inputs, input
is sufficient. For more complicated user inputs, use the SML in results.results - Results containing the user input, including the SML, confidence vales, and
NBest information.
public boolean onComplete()
onComplete in interface IFlowpublic IFlowRenderer createRenderer()
createRenderer in interface IFlowpublic java.lang.String fixupPrompt(java.lang.String item)
fixupPrompt in interface IFlowitem - the tts prompt item to be adjusted
public Grammar fixupGrammar(Grammar gram)
fixupGrammar in interface IFlowgram - a grammar object
public int executionCount()
executionCount in interface IFlowpublic void setExecutionCount(int count)
setExecutionCount in interface IFlowpublic java.lang.String promptGroup()
IFlowFor example, consider a SROLogin class that defines a common login behaviour. It has a prompt id "id:loginFailed" with a default prompt in its prompt XML file. If we use SROLogin several times in our app, we may want to customize the loginFailed prompt each time. Prompt groups allow this. If our first login flow object uses a prompt group of "logon", then the two-stage lookup is: first lookup "id:logon.loginFailed", then "id:loginFailed". Then in our application prompt XML file we'ld add a prompt for "login.loginFailed". Prompt groups are flexible because we can add to the application XML file at any time, without any code changes needed.
promptGroup in interface IFlowpublic void setPromptGroup(java.lang.String groupPrefix)
IFlow
setPromptGroup in interface IFlowgroupPrefix - the prompt group prefix, or "*" which means uses the IFlow's name().public IFlow getSubFlowAfter(IFlow subFlow)
IFlow
getSubFlowAfter in interface IFlowpublic boolean shouldExecute()
IFlow
shouldExecute in interface IFlow
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||