org.jvoicexml.interpreter.formitem
Class ObjectFormItem

java.lang.Object
  extended by org.jvoicexml.interpreter.formitem.ObjectFormItem
All Implemented Interfaces:
CatchContainer, DialogConstruct, EventCountable, FormItem, FormItemLocalExecutableTagContainer, FormItemVisitable, InputItem, PromptCountable

public final class ObjectFormItem
extends Object

This input item invokes a platform-specific object with various parameters. The result of the platform object is an ECMAScript Object. One platform object could be a builtin dialog that gathers credit card information. Another could gather a text message using some proprietary DTMF text entry method. There is no requirement for implementations to provide platform-specific objects, although implementations must handle the <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).

Version:
$Revision: 2129 $
Author:
Dirk Schnelle
See Also:
UnsupportedObjectnameError

Constructor Summary
ObjectFormItem(VoiceXmlInterpreterContext context, VoiceXmlNode voiceNode)
          Creates a new object input item.
 
Method Summary
 void accept(FormItemVisitor visitor)
          Execute the specific method of the visitor.
protected  Object createShadowVarContainer()
          Creates a corresponding shadow var container.
 Collection<AbstractCatchElement> getCatchElements()
          Retrieves all nested catch elements.
 boolean getCondition()
          An expression to evaluate in conjunction with the test of the form item variable.
protected  VoiceXmlInterpreterContext getContext()
          Retrieves the current VoiceXmlInterpreterContext.
 int getEventCount(String type)
          Retrieve the counter for the given event type.
 Object getExpression()
          Selector for the expr attribute.
 Collection<Filled> getFilledElements()
          Gets all nested <filled> elements.
 Object getFormItemVariable()
          Retrieves the form item variable.
 Collection<VoiceXmlNode> getLocalExecutableTags()
          Retrieves the nested tags that have to be executed locally.
 String getName()
          Retrieves the name of this FormItem..
 VoiceXmlNode getNode()
          Retrieves the encapsulated VoiceXmlNode.
 String getNodeTagName()
          Retrieves the tag name of the encapsulated node.
 int getPromptCount()
          Retrieves the value of the prompt counter.
protected  String getShadowVarContainerName()
          Retrieves the name of the corresponding shadow var container name.
 Class<? extends Object> getShadowVariableContainer()
          Retrieves the implementation of the shadow var container for this input item.
 void incrementEventCounter(JVoiceXMLEvent event)
          Increment counters for all events that have the same name as the given event or have a name that is a prefix of the given event.
 void incrementPromptCount()
          Increments the prompt counter.
 void init(ScriptingEngine scripting)
          Initializes this form item.
 boolean isModal()
          Checks if this form item is modal.
 boolean isSelectable()
          Guard conditions, which governs whether or not this form item can be selected by the form interpretation algorithm.
 void resetEventCounter()
          Reset the event counter.
 void resetPromptCount()
          Resets the prompt counter.
protected  void resetShadowVarContainer()
          Reset the shadow var container.
 void setFormItemVariable(Object value)
          Sets the value of the form item variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jvoicexml.interpreter.CatchContainer
getCatchElements
 
Methods inherited from interface org.jvoicexml.interpreter.FormItem
getCondition, getExpression, getFormItemVariable, getName, getNode, getNodeTagName, isSelectable, setFormItemVariable
 
Methods inherited from interface org.jvoicexml.interpreter.PromptCountable
getName, getNode
 

Constructor Detail

ObjectFormItem

public ObjectFormItem(VoiceXmlInterpreterContext context,
                      VoiceXmlNode voiceNode)
Creates a new object input item.

Parameters:
context - The current VoiceXmlInterpreterContext.
voiceNode - The corresponding xml node in the VoiceXML document.
Method Detail

accept

public void accept(FormItemVisitor visitor)
            throws JVoiceXMLEvent
Execute the specific method of the visitor.

Parameters:
visitor - The visitor to use.
Throws:
JVoiceXMLEvent - Error or event visiting the form item.

resetShadowVarContainer

protected void resetShadowVarContainer()
                                throws SemanticError
Reset the shadow var container.

Throws:
SemanticError - error resetting the shadow var container.

getShadowVariableContainer

public Class<? extends Object> getShadowVariableContainer()
Retrieves the implementation of the shadow var container for this input item.

Returns:
null since there is no shadow var container.

isModal

public boolean isModal()
Checks if this form item is modal. This causes all grammars to be disabled except the ones defined in the current form item.

Returns:
true if the form item is modal.

incrementEventCounter

public final void incrementEventCounter(JVoiceXMLEvent event)
Increment counters for all events that have the same name as the given event or have a name that is a prefix of the given event.

Specified by:
incrementEventCounter in interface EventCountable
Parameters:
event - Event to increment.

resetEventCounter

public final void resetEventCounter()
Reset the event counter.

Specified by:
resetEventCounter in interface EventCountable

getPromptCount

public final int getPromptCount()
Retrieves the value of the prompt counter.

Specified by:
getPromptCount in interface PromptCountable
Returns:
Value of the prompt counter.

incrementPromptCount

public final void incrementPromptCount()
Increments the prompt counter.

Specified by:
incrementPromptCount in interface PromptCountable

resetPromptCount

public final void resetPromptCount()
Resets the prompt counter.

Specified by:
resetPromptCount in interface PromptCountable

getEventCount

public final int getEventCount(String type)
Retrieve the counter for the given event type.

Specified by:
getEventCount in interface EventCountable
Parameters:
type - Event type.
Returns:
Count for the given event type.

getShadowVarContainerName

protected final String getShadowVarContainerName()
Retrieves the name of the corresponding shadow var container name.

Returns:
Name of the shadow var container.
Since:
0.3.1

createShadowVarContainer

protected final Object createShadowVarContainer()
                                         throws SemanticError
Creates a corresponding shadow var container.

Returns:
The created host object.
Throws:
SemanticError - Error creating a host object.
Since:
0.5.5

getFilledElements

public final Collection<Filled> getFilledElements()
Gets all nested <filled> elements.

Specified by:
getFilledElements in interface InputItem
Returns:
Collection about all nested <filled> tags.

init

public void init(ScriptingEngine scripting)
          throws SemanticError,
                 BadFetchError
Initializes this form item.

Specified by:
init in interface FormItem
Parameters:
scripting - current scripting engine
Throws:
SemanticError - error initializing this form item
BadFetchError - error initializing this form item

getFormItemVariable

public final Object getFormItemVariable()
Retrieves the form item variable.

Each form has an associated form item variable. which by default is set to ECMA_SCRIPT_UNDEFINED when the form is entered. This form item variable will contain the result of interpreting the form item. An input item's form variable can be given a name using the name attribute or left nameless in which case an internal name is generated.

Specified by:
getFormItemVariable in interface FormItem
Returns:
Result of interpreting this form item.
See Also:
Context.getUndefinedValue()

setFormItemVariable

public void setFormItemVariable(Object value)
                         throws SemanticError
Sets the value of the form item variable.

Specified by:
setFormItemVariable in interface FormItem
Parameters:
value - New value for the form item variable.
Throws:
SemanticError - error setting the value

getName

public final String getName()
Retrieves the name of this FormItem..

Specified by:
getName in interface FormItem
Returns:
Name of a dialog scoped form item variable.

getExpression

public final Object getExpression()
                           throws SemanticError
Selector for the expr attribute.

Specified by:
getExpression in interface FormItem
Returns:
evaluatated expression of the expr attribute.
Throws:
SemanticError - error evaluating the expr attribute.

getCondition

public boolean getCondition()
                     throws SemanticError
An expression to evaluate in conjunction with the test of the form item variable. If absent, this defaults to true, or in the case of <initial>, a test to see if any input item variable has been filled in.

Specified by:
getCondition in interface FormItem
Returns:
true if the cond attribute of the form item evaluates to true.
Throws:
SemanticError - error evaluating the cond attribute.

isSelectable

public boolean isSelectable()
                     throws SemanticError
Guard conditions, which governs whether or not this form item can be selected by the form interpretation algorithm.

This default guard condition just tests to see if the form item variable has a value. If it does, this form item will not be visited.

Specified by:
isSelectable in interface FormItem
Returns:
true if the form item's variable has no value.
Throws:
SemanticError - error evaluating the cond condition.
See Also:
FormItem.getFormItemVariable(), Context.getUndefinedValue()

getNode

public final VoiceXmlNode getNode()
Retrieves the encapsulated VoiceXmlNode.

Specified by:
getNode in interface FormItem
Returns:
Related VoiceXmlNode.

getNodeTagName

public final String getNodeTagName()
Retrieves the tag name of the encapsulated node.

Specified by:
getNodeTagName in interface FormItem
Returns:
tag name of the encapsulated node.

getContext

protected final VoiceXmlInterpreterContext getContext()
Retrieves the current VoiceXmlInterpreterContext.

Returns:
the current VoiceXmlInterpreterContext.

getCatchElements

public Collection<AbstractCatchElement> getCatchElements()
Retrieves all nested catch elements.

Returns:
all nested catch elements

getLocalExecutableTags

public Collection<VoiceXmlNode> getLocalExecutableTags()
Retrieves the nested tags that have to be executed locally.

Specified by:
getLocalExecutableTags in interface FormItemLocalExecutableTagContainer
Returns:
local executable tags.


Copyright © 2005-2010JVoiceXML group.