|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.speakright.core.TrailWrapper
public class TrailWrapper
A wrapper flow object that does nothing except remember which of its methods were called. Uses a Trail object to build a string. Used for unit tests only.
| Field Summary | |
|---|---|
Trail |
m_trail
|
| Constructor Summary | |
|---|---|
TrailWrapper(IFlow flow)
|
|
| Method Summary | |
|---|---|
IFlowRenderer |
createRenderer()
|
void |
execute(IExecutionContext context)
Generates a VoiceXML page, which is sent to the speech platform for execution. |
int |
executionCount()
The number of times this flow has been executed (in the current activation). |
Grammar |
fixupGrammar(Grammar gram)
Callback that lets a flow object do any adjustments on grammars. |
java.lang.String |
fixupPrompt(java.lang.String item)
Callback that lets a flow object do any adjustments on prompt text. |
IFlow |
getFirst(IFlowContext context)
Gets the first sub-flow to be executed. |
IFlow |
getNext(IFlow current,
SRResults results)
Gets the next flow object to be executed. |
IFlow |
getSubFlowAfter(IFlow subFlow)
Return the next sub-flow after subFlow. |
IFlow |
InnerFlow()
|
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 first method called when a flow is executed. |
IFlow |
onCatch(IFlow current,
SRResults results,
java.lang.String eventName,
ThrowEvent event)
Event handler for custom events. |
boolean |
onComplete()
Do any side-effects that should be done when the flow finishes, such as updating a database. |
IFlow |
onDisconnect(IFlow current,
SRResults results)
Event handler for a disconnect event. |
void |
onEnd(IFlowContext context)
The last method called when a flow is executed. |
IFlow |
onNoInput(IFlow current,
SRResults results)
Event handler for the no-input event. |
IFlow |
onPlatformError(IFlow current,
SRResults results)
Event handler for a error returned by the speech platform. |
IFlow |
onTransferFailed(IFlow current,
SRResults results)
Event handler for a failed transfer. |
IFlow |
onValidateFailed(IFlow current,
SRResults results)
Event handler for validation failed. |
java.lang.String |
promptGroup()
The prompt group prefix applies to prompt ids. |
void |
setExecutionCount(int count)
Used internally by SRInstance. |
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)
Validates user input. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Trail m_trail
| Constructor Detail |
|---|
public TrailWrapper(IFlow flow)
| Method Detail |
|---|
public IFlow InnerFlow()
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 execute(IExecutionContext context)
IFlowExecute may choose to generate no content; this is called an "empty" flow object. Execute may also choose to generate a flow event. This is used for error conditions where the application can't proceed and needs to jump to a different flow. For example, Execute may want to access a web service to play weather information. If the web service is down, a flow event can be thrown.
execute in interface IFlowcontext - Contains the page renderer.public IFlow getFirst(IFlowContext context)
IFlowReturning null is not allowed. Some exceptions to this exist; BasicFlow supports "optional" sub-flows where a sub-flow returns null from getFirst to indicate that it doesn't wish to run. However the outer flow object (BasicFlow) ensures that its getFirst never returns null.
getFirst may be called more than once per activation (see BasicFlow).
getFirst in interface IFlow
public IFlow getNext(IFlow current,
SRResults results)
IFlow
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)
IFlow
onBegin in interface IFlowpublic void onEnd(IFlowContext context)
IFlow
onEnd in interface IFlow
public IFlow onDisconnect(IFlow current,
SRResults results)
IFlowThe SRApp class provides a default implementation that returns an ExitEvent.
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)
IFlowNo-Input only applies if the VoiceXML has active grammars. An output only page does not generate this event.
SRApp provides a default implementation that transfers the call to the operator. In some cases, No-Input is a valid event. For example, a flow object that reads a long weather bulletin may be listening for "stop" or "cancel". If the caller listens to the whole bulletin without speaking, a No-Input will be returned. The application ignores the No-Input by overriding onNoInput in the flow object, and having it return its normal getNext value.
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)
IFlow
Event handling in SpeakRight involves a search up the flow stack. First the currently
executing flow (current) is checked. If its event handler returns non-null
then the event has been handled. Otherwise the next flow object on the flow stack is checked,
up to the outermost flow object (the application flow object).
It is an error for an event not to be caught. SRApp provides default handlers for
all events.
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)
IFlowThe SRApp class provides a default implementation that transfers the call to an operator.
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)
IFlowThe SRApp class provides a default implementation that transfers the call to an operator.
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)
IFlow
The default implementation of onValidateFailed is to return this, which causes
the flow object to be executed again. The ExecutionCount field can
be used to detect re-execution, and generate a retry prompt. FlowBase provides
the default implemenation.
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)
IFlowFlowBase provides the default implementation, which simply returns true.
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()
IFlow
onComplete in interface IFlowpublic IFlowRenderer createRenderer()
createRenderer in interface IFlowpublic java.lang.String fixupPrompt(java.lang.String item)
IFlow
fixupPrompt in interface IFlowitem - the tts prompt item to be adjusted
public Grammar fixupGrammar(Grammar gram)
IFlow
fixupGrammar in interface IFlowgram - a grammar object
public int executionCount()
IFlow
executionCount in interface IFlowpublic void setExecutionCount(int count)
IFlow
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 | |||||||||