org.jvoicexml.interpreter.tagstrategy
Class IfStrategy

java.lang.Object
  extended by org.jvoicexml.interpreter.tagstrategy.IfStrategy
All Implemented Interfaces:
Cloneable, TagStrategy

public final class IfStrategy
extends Object

Strategy of the FIA to execute an <if> node.

This class is also responsible to handle the <else> and <elseif> tags since they can appear only as children of the <if> tag.

Version:
$Revision: 2739 $
Author:
Dirk Schnelle-Walka
See Also:
FormInterpretationAlgorithm, If

Method Summary
 Object clone()
           The evaluated attributes are cloned via a shallow copy.
 void dumpNode(VoiceXmlNode node)
          Debugging facility to display the contents of all attributes in the node.
 void evalAttributes(VoiceXmlInterpreterContext context)
          Evaluates all attributes which have to be evaluated by the scripting environment.
 void execute(VoiceXmlInterpreterContext context, VoiceXmlInterpreter interpreter, FormInterpretationAlgorithm fia, FormItem item, VoiceXmlNode node)
          Executes the strategy with the current parameters.
 void executeLocal(VoiceXmlInterpreterContext context, VoiceXmlInterpreter interpreter, FormInterpretationAlgorithm fia, FormItem item, VoiceXmlNode node)
          Executes the strategy with the current parameters local to a form item.
protected  Object getAttribute(String name)
          Retrieves the value of the given attribute.
 void getAttributes(VoiceXmlInterpreterContext context, FormInterpretationAlgorithm fia, VoiceXmlNode node)
          Retrieves all attributes specified by the given node or by a <property> tag and stores their values in the working copy of this strategy.
 Collection<String> getEvalAttributes()
          Retrieves the names of all attributes, which have to be evaluated by the scripting environment.
protected  boolean isAttributeDefined(String name)
          Checks if the given attribute is defined, this means, neither null nor Context.getUndefinedValue().
 TagStrategy newInstance()
          Factory method to get a new instance of this strategy.
 void validateAttributes()
          Validates the attributes of the current node.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEvalAttributes

public Collection<String> getEvalAttributes()
Retrieves the names of all attributes, which have to be evaluated by the scripting environment.

The evaluation is done with a more general algorithm in the execute(VoiceXmlInterpreterContext, VoiceXmlInterpreter, FormInterpretationAlgorithm, FormItem, VoiceXmlNode) method.

Returns:
Names of all attributes to be evaluated, null if the related node has not attributes to be evaluated.

execute

public void execute(VoiceXmlInterpreterContext context,
                    VoiceXmlInterpreter interpreter,
                    FormInterpretationAlgorithm fia,
                    FormItem item,
                    VoiceXmlNode node)
             throws JVoiceXMLEvent
Executes the strategy with the current parameters. Find the child nodes to execute and execute them.

Parameters:
context - The VoiceXML interpreter context.
interpreter - The current VoiceXML interpreter.
fia - The current form interpretation algorithm, maybe null if there is no current fia.
item - The current form item,maybe null if there is no current form item.
node - The current child node.
Throws:
JVoiceXMLEvent - Error while executing this strategy.

newInstance

public TagStrategy newInstance()
Factory method to get a new instance of this strategy.

Specified by:
newInstance in interface TagStrategy
Returns:
Strategy that can be used in the FIA.
See Also:
FormInterpretationAlgorithm

getAttributes

public void getAttributes(VoiceXmlInterpreterContext context,
                          FormInterpretationAlgorithm fia,
                          VoiceXmlNode node)
Retrieves all attributes specified by the given node or by a <property> tag and stores their values in the working copy of this strategy.

Retrieves all attributes of the current tag and store their values in the attributes map. If there is no value in the prompt, the method tries to find a value that has been set via a <property> tag.
Implementations are requested to obtain the values via the getAttribute(String) method.

Specified by:
getAttributes in interface TagStrategy
Parameters:
context - The current VoiceXML interpreter context.
fia - The current form interpretation algorithm, maybe null if there is no current fia.
node - The node to process.

evalAttributes

public void evalAttributes(VoiceXmlInterpreterContext context)
                    throws SemanticError
Evaluates all attributes which have to be evaluated by the scripting environment.

Specified by:
evalAttributes in interface TagStrategy
Parameters:
context - The current VoiceXML interpreter context.
Throws:
SemanticError - Error evaluating a variable.

validateAttributes

public void validateAttributes()
                        throws ErrorEvent
Validates the attributes of the current node. Check, if all needed attributes are provided.

Specified by:
validateAttributes in interface TagStrategy
Throws:
ErrorEvent - Validation failed.

clone

public Object clone()
The evaluated attributes are cloned via a shallow copy.

Overrides:
clone in class Object

getAttribute

protected Object getAttribute(String name)
Retrieves the value of the given attribute.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute, null if the attribute has no associated value.

isAttributeDefined

protected boolean isAttributeDefined(String name)
Checks if the given attribute is defined, this means, neither null nor Context.getUndefinedValue().

Parameters:
name - Name of the attribute.
Returns:
true if the attribute is defined.

dumpNode

public void dumpNode(VoiceXmlNode node)
Debugging facility to display the contents of all attributes in the node.

Specified by:
dumpNode in interface TagStrategy
Parameters:
node - The current node.

executeLocal

public void executeLocal(VoiceXmlInterpreterContext context,
                         VoiceXmlInterpreter interpreter,
                         FormInterpretationAlgorithm fia,
                         FormItem item,
                         VoiceXmlNode node)
                  throws JVoiceXMLEvent
Executes the strategy with the current parameters local to a form item.

Specified by:
executeLocal in interface TagStrategy
Parameters:
context - The VoiceXML interpreter context.
interpreter - The current VoiceXML interpreter.
fia - The current form interpretation algorithm, maybe null if there is no current fia.
item - The current form item,maybe null if there is no current form item.
node - The current child node.
Throws:
JVoiceXMLEvent - Error while executing this strategy.


Copyright © 2005-2010JVoiceXML group.