public final class FormInterpretationAlgorithm extends java.lang.Object implements FormItemVisitor
Interpreting a form item generally involves:
<filled> action that pertained todo
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.
Form,
Dialog,
VoiceXmlInterpreter| Constructor and Description |
|---|
FormInterpretationAlgorithm(VoiceXmlInterpreterContext ctx,
VoiceXmlInterpreter ip,
Dialog currentDialog)
Construct a new FIA object.
|
| Modifier and Type | Method and Description |
|---|---|
Dialog |
getDialog()
Retrieves the current dialog.
|
FormItem |
getFormItem()
Retrieves the currently processed
FormItem. |
FormItem |
getFormItem(java.lang.String name)
Retrieves the
FormItem with the given name. |
java.util.Collection<FormItem> |
getFormItems()
Retrieves all
FormItems of the current dialog of the current
dialog. |
java.lang.String |
getLocalProperty(java.lang.String name)
Retrieves the value of the given property.
|
TagStrategyExecutor |
getTagStrategyExecutor()
Retrieves the tag strategy executor.
|
VoiceXmlInterpreterContext |
getVoiceXmlInterpreterContext()
Retrieves the current
VoiceXmlInterpreterContext. |
void |
initialize(Profile prof,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Implementation of the initialization phase.
|
boolean |
isJustFilled(InputItem input)
Checks, if the
just_filled flag is set for the given input
item. |
boolean |
isQueuingPrompts()
Checks if the FIA is currently queuing prompts.
|
void |
mainLoop()
The main loop of the FIA has three phases:
The select phase: The next unfilled
FormItem for
visiting. |
GrammarDocument |
processGrammar(org.jvoicexml.xml.srgs.Grammar grammar)
Processes the given grammar tag and adds it to the
ActiveGrammarSet. |
void |
setJustFilled(InputItem input)
Sets the
just_filled flag for the given input item. |
void |
setLocalProperty(java.lang.String name,
java.lang.String value)
Sets the property with the given name to the given value.
|
void |
setReprompt(boolean on)
Set if the last loop iteration ended with a
<catch>
that had no <reprompt>. |
void |
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. |
void |
visitFieldFormItem(InputItem field)
If a
<field> is visited, the FIA selects and queues
up any prompts based on the item's prompt counter and prompt
conditions. |
void |
visitInitialFormItem(InitialFormItem initial)
This element controls the initial interaction in a mixed initiative form.
|
void |
visitObjectFormItem(ObjectFormItem object)
This input item invokes a platform-specific object with various
parameters.
|
void |
visitRecordFormItem(RecordFormItem record)
An input item whose value is an audio clip recorded by the user.
|
void |
visitSubdialogFormItem(SubdialogFormItem subdialog)
A
<subdialog> input item is roughly like a function
call. |
void |
visitTransferFormItem(TransferFormItem transfer)
An input item which transfers the user to another telephone number.
|
public FormInterpretationAlgorithm(VoiceXmlInterpreterContext ctx, VoiceXmlInterpreter ip, Dialog currentDialog)
ctx - the VoiceXML interpreter context.ip - the VoiceXML interpreter.currentDialog - the dialog to be interpreted.public Dialog getDialog()
public VoiceXmlInterpreterContext getVoiceXmlInterpreterContext()
VoiceXmlInterpreterContext.VoiceXmlInterpreterContext.public TagStrategyExecutor getTagStrategyExecutor()
public void initialize(Profile prof, java.util.Map<java.lang.String,java.lang.Object> parameters) throws JVoiceXMLEvent
Whenever a dialog is entered, it is initialized. Internal prompt counter
variables (in the dialog's dialog scope) are reset to 1. Each variable
(form level <var> elements and FormItem
variable is initialized, in document order, to undefined or to the value
of the relevant <expr> attribute.
prof - the profileparameters - passed parameters when executing this dialogJVoiceXMLEvent - Error initializing the FormItems.public FormItem getFormItem(java.lang.String name)
FormItem with the given name.public java.util.Collection<FormItem> getFormItems()
FormItems of the current dialog of the current
dialog.FormItems.public FormItem getFormItem()
FormItem.public void mainLoop()
throws JVoiceXMLEvent
The select phase: The next unfilled FormItem for
visiting.
The collect phase: the selected FormItem 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
FormItems 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 dialog.public void setJustFilled(InputItem input)
just_filled flag for the given input item.input - the input item.public boolean isJustFilled(InputItem input)
just_filled flag is set for the given input
item.input - the input itemtrue if the flag is set.public boolean isQueuingPrompts()
TagStrategys might be different dependent on the queuing mode.true if the FIA is currently queiung prompts.public GrammarDocument processGrammar(org.jvoicexml.xml.srgs.Grammar grammar) throws UnsupportedFormatError, NoresourceError, BadFetchError, SemanticError
ActiveGrammarSet.grammar - grammar to process.NoresourceError - Error accessing the input device.UnsupportedFormatError - If an unsupported grammar has to be processed.BadFetchError - If the document could not be fetched successfully.SemanticError - if there was an error evaluating a scripting expressionpublic void 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 dialog
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 void visitFieldFormItem(InputItem field) throws JVoiceXMLEvent
<field> is visited, the FIA selects and queues
up any prompts based on the item's prompt 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's prompt 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 input form item to visit.JVoiceXMLEvent - Error or event executing the field.public void 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 void visitObjectFormItem(ObjectFormItem object) 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 FormItemVisitorobject - The object form item to visit.JVoiceXMLEvent - Error or event executing the object form item.public void 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 void 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 void 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 setReprompt(boolean on)
<catch>
that had no <reprompt>.on - true if a catch occurred that had no reprompt.public java.lang.String getLocalProperty(java.lang.String name)
name - Name of the property.public void setLocalProperty(java.lang.String name,
java.lang.String value)
name - Name of the property.value - Value of the property.