org.jvoicexml.interpreter.scripting
Class RhinoScriptingEngine

java.lang.Object
  extended by org.jvoicexml.interpreter.scripting.RhinoScriptingEngine
All Implemented Interfaces:
ScopeSubscriber, ScriptingEngine

public final class RhinoScriptingEngine
extends Object
implements ScriptingEngine, ScopeSubscriber

Container for the handling of variables.

Version:
$Revision: 216 $

Copyright © 2005-2007 JVoiceXML group - http://jvoicexml.sourceforge.net/

Author:
Torben Hardt, Dirk Schnelle

Constructor Summary
RhinoScriptingEngine(VoiceXmlInterpreterContext ctx)
          Constructs a new object.
 
Method Summary
<T> T
createHostObject(String name, Class<T> template)
          Creates a host object in the scripting engine from the given java object.
 void enterScope(Scope previous, Scope next)
          The application has entered the next scope and the previous scope is no more the current scope.
 Object eval(String expr)
          Evaluates the given expression.
 void exitScope(Scope previous, Scope next)
          The application has left the previous scope and the next scope is valid.
 Object getVariable(String name)
          Gets the variables current value.
 boolean isVariableDefined(String name)
          Checks, if the given variable is defined.
 void removeVariable(String name)
          Removes the given variable from the vault.
 void setVariable(String name, Object value)
          Sets a existing variable to a new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RhinoScriptingEngine

public RhinoScriptingEngine(VoiceXmlInterpreterContext ctx)
Constructs a new object.

Parameters:
ctx - The current VoiceXML interpreter context.
Method Detail

eval

public Object eval(String expr)
            throws SemanticError
Evaluates the given expression.

Specified by:
eval in interface ScriptingEngine
Parameters:
expr - The expression to evaluate.
Returns:
Evaluating result.
Throws:
SemanticError - Error evaluating the expression.

setVariable

public void setVariable(String name,
                        Object value)
Sets a existing variable to a new value.

Specified by:
setVariable in interface ScriptingEngine
Parameters:
name - unique identifier
value - the new value of the variable

getVariable

public Object getVariable(String name)
Gets the variables current value.

Specified by:
getVariable in interface ScriptingEngine
Parameters:
name - unique identifier
Returns:
the variables value object

removeVariable

public void removeVariable(String name)
Removes the given variable from the vault.

Specified by:
removeVariable in interface ScriptingEngine
Parameters:
name - unique identifier.

isVariableDefined

public boolean isVariableDefined(String name)
Checks, if the given variable is defined.

Specified by:
isVariableDefined in interface ScriptingEngine
Parameters:
name - Name of the variable to check.
Returns:
true if the variable is defined.

enterScope

public void enterScope(Scope previous,
                       Scope next)
The application has entered the next scope and the previous scope is no more the current scope.

Specified by:
enterScope in interface ScopeSubscriber
Parameters:
previous - The old scope.
next - The new scope.

exitScope

public void exitScope(Scope previous,
                      Scope next)
The application has left the previous scope and the next scope is valid.

Specified by:
exitScope in interface ScopeSubscriber
Parameters:
previous - The old scope.
next - The new scope.

createHostObject

public <T> T createHostObject(String name,
                              Class<T> template)
                   throws SemanticError
Creates a host object in the scripting engine from the given java object.

Specified by:
createHostObject in interface ScriptingEngine
Type Parameters:
T - Type of the host object.
Parameters:
name - Name of the shadow variable.
template - Base class of the host object.
Returns:
Created object.
Throws:
SemanticError - Error converting the given object to a host object.


Copyright © 2005-2007 JVoiceXML group.