|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jvoicexml.interpreter.FormInterpretationAlgorithm
public final class FormInterpretationAlgorithm
Forms are interpreted by an implicit form interpretation algorithm (FIA). The fia has a main loop that repeatedly selects a form item and then visits it. The selected form item is the first in document order whose guard condition is not satisfied. For instance, a field's default guard condition tests to see if the field's form item variable has a value, so that if a simple form contains only fields, the user will be prompted for each field in turn.
Interpreting a form item generally involves:
<filled> action that pertained to
the newly filled in input items.
The FIA ends when it interprets a transfer of control statements (e.g. a
<goto> to another dialog or document or a
<submit> of data to the document server). It also ends
with an implied <exit> when no form item remains eglible
to select.
Copyright © 2005-2006 JVoiceXML group - http://jvoicexml.sourceforge.net/
Form,
VoiceXmlInterpreter| Field Summary | |
|---|---|
private VoiceXmlInterpreterContext |
context
The current VoiceXML interpreter context. |
private ExecutableForm |
form
The form to be processed by this FIA. |
private Collection<FormItem> |
formItems
Form items of the current form. |
private String |
id
The id of the form. |
private VoiceXmlInterpreter |
interpreter
The current VoiceXML interpreter. |
private static Logger |
LOGGER
Logger for this class. |
private boolean |
reprompt
true if the last loop iteration ended with a catch that had
no <reprompt>. |
private TagStrategyFactory |
tagstrategyFactory
The factory for tag strategies. |
| Constructor Summary | |
|---|---|
FormInterpretationAlgorithm(VoiceXmlInterpreterContext ctx,
VoiceXmlInterpreter ip,
ExecutableForm currentForm)
Construct a new FIA object. |
|
| Method Summary | |
|---|---|
private void |
activateGrammars(FormItem item)
Activate grammars for the form item. |
private EventHandler |
collect(FormItem item)
Implementation of the collect phase: the selected form item is visited, which prompts the user for input, enables the appropriate grammars, and then waits for and collects an input (such as a spoken phrase or DTMF key presses) or an event (such as a request for help or a no input timeout). |
private void |
createShadowVarContainer(FormItem item)
Creates a corresponding shadow var container, if the given form item is an InputItem. |
void |
createVariable(String name,
String expr)
Creates the var with the given name and a value of the evaluated expression. |
void |
executeChildNodes(FormItem item)
Execute the tag strategies for all child nodes of the given form item. |
void |
executeChildNodes(FormItem item,
NodeList list)
Execute the TagStrategy for all nodes of the given list. |
void |
executeChildNodes(FormItem item,
VoiceXmlNode parent)
Execute the TagStrategy for all child nodes of the given
parent node. |
FormItem |
getFormItem(String name)
Retrieves the form item with the given name. |
Collection<FormItem> |
getFormItems()
Retrieves all form items of the current form. |
VoiceXmlInterpreterContext |
getVoiceXmlInterpreterContext()
Retrieve the current VoiceXmlInterpreterContext. |
private void |
initFormItem(FormItem item)
Initializes the given FormItem |
void |
initialize()
Implementation of the initialization phase. |
void |
mainLoop()
The main loop of the FIA has three phases: The select phase: The next unfilled form item for visiting. |
private void |
process(FormItem item,
EventHandler handler)
Implementation of the process phase. |
private void |
queuePrompt(Prompt prompt)
Queue the prompt to the output device. |
private void |
queuePrompts(PromptCountable countable)
Selects the appropriate prompts for an input item or <initial>. |
private FormItem |
select()
Implementation of the select phase: the next unfilled form item is selected for visiting. |
private FormItem |
select(String name)
Select the next form item as a result of a <goto>. |
void |
setReprompt(boolean on)
Set if the last loop iteration ended with a <catch>
that had no <reprompt>. |
EventHandler |
visitBlockFormItem(BlockFormItem block)
A <block> element is visited by setting its form
item variable to true, evaluating its content, and then
bypassing the process phase.
A <block> element is visited by setting its form
item variable to true, evaluating its content, and then
bypassing the process phase. |
EventHandler |
visitFieldFormItem(FieldFormItem field)
If a <field> is visited, the FIA selects and queues
up any prompts based on the item'sprompt counter and prompt
conditions.
If a <field> is visited, the FIA selects and queues
up any prompts based on the item'sprompt counter and prompt conditions. |
EventHandler |
visitInitialFormItem(InitialFormItem initial)
This element controls the initial interaction in a mixed initiative form. |
EventHandler |
visitObjectFormItem(ObjectFormItem ojbect)
This input item invokes a platform-specific object with various parameters. |
EventHandler |
visitRecordFormItem(RecordFormItem record)
An input item whose value is an audio clip recorded by the user. |
EventHandler |
visitSubdialogFormItem(SubdialogFormItem subdialog)
A <>subdialog> input item is roughly like a function
call. |
EventHandler |
visitTransferFormItem(TransferFormItem transfer)
An input item which transfers the user to another telephone number. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final Logger LOGGER
private final ExecutableForm form
private final String id
private Collection<FormItem> formItems
private final VoiceXmlInterpreterContext context
private final VoiceXmlInterpreter interpreter
private final TagStrategyFactory tagstrategyFactory
private boolean reprompt
true if the last loop iteration ended with a catch that had
no <reprompt>.
| Constructor Detail |
|---|
public FormInterpretationAlgorithm(VoiceXmlInterpreterContext ctx,
VoiceXmlInterpreter ip,
ExecutableForm currentForm)
ctx - The VoiceXML interpreter context.ip - The VoiceXML interpreter.currentForm - The Form to be interpreted.| Method Detail |
|---|
public VoiceXmlInterpreterContext getVoiceXmlInterpreterContext()
VoiceXmlInterpreterContext.
VoiceXmlInterpreterContext.public void initialize()
Whenever a form is entered, it is initialized. Internal prompt counter
variables (in the form's dialog scope) are reset to 1. Each variable
(form level <var> elements and form item variable is
initialized, in document order, to undefined or to the value of the
relevant <expr> attribute.
private void initFormItem(FormItem item)
FormItem
item - The item to initialize.public FormItem getFormItem(String name)
name - Name of the form item
null if it does not
exist.public Collection<FormItem> getFormItems()
public void createVariable(String name,
String expr)
name - Name of the var to create.expr - Expression to be evaluated.
public void mainLoop()
throws JVoiceXMLEvent
The select phase: The next unfilled form item for visiting.
The collect phase: the selected form item is visited, which prompts the user for input, enables the appropriate grammars, and then waits for and collects an input (such as a spoken phrase or DTMF key presses) or an event (such as a request for help or a no input timeout.
The process phase: an input is processed by filling form items
and executing <var> elements to perform input
validation. An event is processed by executing the appropriate event
handler for that event type.
JVoiceXMLEvent - Error or event processing the form.private FormItem select()
The purpose of the select phase is to select the next form item to visit. This is done as follows:
If a <goto> from the last main loop iteration's
process phase specified a <goto nextitem> then the
specified form item is selected.
Otherwise the first form item whose guard condition is false is chosen to be visited. If an error occurs while checking the guard conditions, the event is thrown which skips the collect phase, and is handled in the process phase.
If no guard condition is false, and the last iteration completed the form
without encountering an explicit transfer of control, the FIA does an
implicit <exit> operation (similarly, if execution
proceeds outside of a form, such as when an error is generated outside of
a form, and there is no explicit transfer of control, the interpreter
will perform an implicit <exit> operation).
null if there is none.private FormItem select(String name)
<goto>.
name - name of the next form item.
FormItem, null if there is no
form item with that name.
private EventHandler collect(FormItem item)
throws JVoiceXMLEvent
The purpose of the collect phase is to collect an input or an event. The selected form item is visited, which performs actions that depend on the type of form item.
item - The form item to visit.
JVoiceXMLEvent - Error or event visiting the form item.select()
private void process(FormItem item,
EventHandler handler)
throws JVoiceXMLEvent
item - The current form item.handler - The event handler.
JVoiceXMLEvent - Error processing the event.
private void createShadowVarContainer(FormItem item)
throws SemanticError
InputItem.
item - The potential InputItem.
SemanticError - Error creating a host object.InputItem
private void queuePrompts(PromptCountable countable)
throws JVoiceXMLEvent
<initial>.
Queue the selected prompts for play prior to the next collect operation.
countable - The prompt countable.
JVoiceXMLEvent - Error collecting the prompts or in ptompt evaluation.
private void queuePrompt(Prompt prompt)
throws NoresourceError,
BadFetchError
prompt - The prompt to play back
NoresourceError - No output device configured.
BadFetchError - Error evaluating a script within the prompt.
private void activateGrammars(FormItem item)
throws BadFetchError,
UnsupportedLanguageError,
NoresourceError,
UnsupportedFormatError
item - The form item for which the grammars should be activated.
BadFetchError - Error retrieving the grammar from the given URI.
UnsupportedLanguageError - The specified language is not supported.
NoresourceError - The input resource is not available.
UnsupportedFormatError - Error in the grammar's format.
public EventHandler visitBlockFormItem(BlockFormItem block)
throws JVoiceXMLEvent
<block> element is visited by setting its form
item variable to true, evaluating its content, and then
bypassing the process phase. No input is collected, and the next
iteration of the FIA's main loop is entered.
A <block> element is visited by setting its form
item variable to true, evaluating its content, and then
bypassing the process phase.
visitBlockFormItem in interface FormItemVisitorblock - The block form item to visit.
JVoiceXMLEvent - Error or event executing the block.
public EventHandler visitFieldFormItem(FieldFormItem field)
throws JVoiceXMLEvent
<field> is visited, the FIA selects and queues
up any prompts based on the item'sprompt counter and prompt
conditions. Then it activates and listens for the field level
grammar(s) and any higher-level grammars, and waits for the item
to be filled or for some events to be generated.
If a <field> is visited, the FIA selects and queues
up any prompts based on the item'sprompt counter and prompt conditions.
Then it activates and listens for the field level grammar(s) and any
higher-level grammars, and waits for the item to be filled or for some
events to be generated.
visitFieldFormItem in interface FormItemVisitorfield - The field form item to visit.
JVoiceXMLEvent - Error or event executing the field.
public EventHandler visitInitialFormItem(InitialFormItem initial)
throws JVoiceXMLEvent
<initial>
element, the form item variable of <initial> becomes
true, thus removing it as an alternative for the FIA.
visitInitialFormItem in interface FormItemVisitorinitial - The field form item to visit.
JVoiceXMLEvent - Error or event executing the initial form item.
public EventHandler visitObjectFormItem(ObjectFormItem ojbect)
throws JVoiceXMLEvent
<object> element by throwing
error.unsupported.objectname if the particular
platform-specific object is not supported (note that
objectname in error.unsupported.objectname is
a fixed string, so not substituted with the name of the unsupported
object; more specific error information may be provided in the event
_message special variable as described in
Section 5.2.2).
visitObjectFormItem in interface FormItemVisitorojbect - The object form item to visit.
JVoiceXMLEvent - Error or event executing the object form item.
public EventHandler visitRecordFormItem(RecordFormItem record)
throws JVoiceXMLEvent
<record> element could collect a voice mail message,
for instance.
visitRecordFormItem in interface FormItemVisitorrecord - The record form item to visit.
JVoiceXMLEvent - Error or event executing the record form item.
public EventHandler visitSubdialogFormItem(SubdialogFormItem subdialog)
throws JVoiceXMLEvent
<>subdialog> input item is roughly like a function
call. It invokes another dialog on the current page, or invokes another
VoiceXML document. It returns an ECMAScript Object as its result.
visitSubdialogFormItem in interface FormItemVisitorsubdialog - The subdialog form item to visit.
JVoiceXMLEvent - Error or event executing the subdialog form item.
public EventHandler visitTransferFormItem(TransferFormItem transfer)
throws JVoiceXMLEvent
visitTransferFormItem in interface FormItemVisitortransfer - The transfer form item to visit.
JVoiceXMLEvent - Error or event executing the transfer form item.
public void executeChildNodes(FormItem item)
throws JVoiceXMLEvent
item - The current form item.
JVoiceXMLEvent - Error or event executing the child node.
public void executeChildNodes(FormItem item,
VoiceXmlNode parent)
throws JVoiceXMLEvent
TagStrategy for all child nodes of the given
parent node.
item - The current form item.parent - The parent node, which is in fact a child to item.
JVoiceXMLEvent - Error or event executing the child node.TagStrategy
public void executeChildNodes(FormItem item,
NodeList list)
throws JVoiceXMLEvent
TagStrategy for all nodes of the given list.
item - The current form item.list - The list of nodes to execute.
JVoiceXMLEvent - Error or event executing the child node.TagStrategypublic void setReprompt(boolean on)
<catch>
that had no <reprompt>.
on - true if a catch occured that had no reprompt.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||