org.jvoicexml.interpreter.formitem
Class TransferFormItem

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

public final class TransferFormItem
extends Object

An input item which transfers the user to another telephone number. If the transfer returns control, the field variable will be set to the result status.

Version:
$Revision: 2715 $
Author:
Dirk Schnelle-Walka

Constructor Summary
TransferFormItem(VoiceXmlInterpreterContext context, VoiceXmlNode voiceNode)
          Create a new transfer input item.
 
Method Summary
 void accept(FormItemVisitor visitor)
          Execute the specific method of the visitor.
protected  void addCustomGrammars(Collection<Grammar> grams)
          Adds custom grammars of the grammar container.
 void addGrammar(GrammarDocument document)
          Adds the given converted grammar to the list of converted grammars for this field.
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.
 String getDest()
          Retrieves the destination of this transfer by evaluating the dest and the destexpr attributes.
 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<Grammar> getGrammars()
          Get all nested definitions of a <grammar>.
 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 isBridged()
          Checks if the requested transfer is a bridge transfer.
 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.InputItem
getFilledElements
 
Methods inherited from interface org.jvoicexml.interpreter.CatchContainer
getCatchElements
 
Methods inherited from interface org.jvoicexml.interpreter.FormItem
getCondition, getExpression, getFormItemVariable, getName, getNode, getNodeTagName, init, isSelectable, setFormItemVariable
 
Methods inherited from interface org.jvoicexml.interpreter.PromptCountable
getName, getNode, getPromptCount, incrementPromptCount, resetPromptCount
 
Methods inherited from interface org.jvoicexml.interpreter.EventCountable
getEventCount, incrementEventCounter, resetEventCounter
 

Constructor Detail

TransferFormItem

public TransferFormItem(VoiceXmlInterpreterContext context,
                        VoiceXmlNode voiceNode)
Create a new transfer 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:
Class of the shadow var container, null if there is no shadow var container.

getDest

public String getDest()
               throws SemanticError,
                      BadFetchError
Retrieves the destination of this transfer by evaluating the dest and the destexpr attributes.

Returns:
destination of this transfer.
Throws:
SemanticError - Error evaluating the destexpr attribute.
BadFetchError - No destination specified.
Since:
0.7 TODO evaluate the telephone URI after RFC2806

isBridged

public boolean isBridged()
Checks if the requested transfer is a bridge transfer.

Returns:
true if the requested transfer is bridged.

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.

addGrammar

public void addGrammar(GrammarDocument document)
Adds the given converted grammar to the list of converted grammars for this field.

Specified by:
addGrammar in interface GrammarContainer
Parameters:
document - the processed grammar document

addCustomGrammars

protected void addCustomGrammars(Collection<Grammar> grams)
Adds custom grammars of the grammar container.

Parameters:
grams - already found grammars

getGrammars

public final Collection<Grammar> getGrammars()
Get all nested definitions of a <grammar>.

Specified by:
getGrammars in interface GrammarContainer
Returns:
Collection about all nested <grammar> tags.

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.