org.jvoicexml.interpreter
Class VoiceXmlInterpreterContext

java.lang.Object
  extended by org.jvoicexml.interpreter.VoiceXmlInterpreterContext

public final class VoiceXmlInterpreterContext
extends Object

Component that uses a VoiceXML interpreter to interpret a VoiceXML document and that may also interact with the implementation platform independent of the VoiceXML interpreter.

Version:
$LastChangedRevision: 2913 $
Author:
Dirk Schnelle-Walka, Torben Hardt

Constructor Summary
VoiceXmlInterpreterContext(JVoiceXmlSession currentSession, Configuration config)
          Create a new object.
VoiceXmlInterpreterContext(JVoiceXmlSession currentSession, Configuration config, ScopeObserver observer)
          Create a new object.
 
Method Summary
 GrammarDocument acquireExternalGrammar(URI uri, FetchAttributes attributes)
          Acquire the VoiceXML document with the given URI.
 VoiceXmlDocument acquireVoiceXmlDocument(DocumentDescriptor descriptor)
          Acquires the VoiceXML document with the given URI.
 void close()
          Closes all open resources.
 void enterScope(Scope scope)
          Enter a new scope for resolving variables. this is useful if we enter a new block, but at least every file should have it's own scope.
 void exitScope(Scope scope)
          Return from a previously created scope. i.e. pop current scope from stack.
 ActiveGrammarSet getActiveGrammarSet()
          Retrieves the active grammar set.
 Application getApplication()
          Retrieves the application.
 CallControlProperties getCallControlProperties(FormInterpretationAlgorithm fia)
          Loads the speech recognizer properties.
 Configuration getConfiguration()
          Retrieves the configuration.
 DocumentServer getDocumentServer()
          Retrieves a reference to the document server.
 DtmfRecognizerProperties getDtmfRecognizerProperties(FormInterpretationAlgorithm fia)
          Loads the DTMF recognizer properties.
 EventHandler getEventHandler()
          Retrieves the event handler to use in this context.
 GrammarProcessor getGrammarProcessor()
          Retrieves a reference to the grammar processor.
 ImplementationPlatform getImplementationPlatform()
          Retrieves a reference to the used implementation platform.
 String getProperty(String name)
          Retrieves the value of the given property.
 String getProperty(String name, String defValue)
          Retrieves the value of the given property.
 ScopeObserver getScopeObserver()
          Retrieves the scope observer for this session.
 ScriptingEngine getScriptingEngine()
          Lazy instantiation of the scripting engine.
 Session getSession()
          Retrieves the current session.
 SpeechRecognizerProperties getSpeechRecognizerProperties(FormInterpretationAlgorithm fia)
          Loads the speech recognizer properties.
 boolean isInitializingSubdialog()
          Checks if the interpreter is in the initialzing phase of a subdialog.
 VoiceXmlDocument loadDocument(DocumentDescriptor descriptor)
          Loads the document of the descriptor with the associated attributes and adds it to the list of loaded documents.
 void process(Application appl)
          Starts processing the given application.
 void processSubdialog(Application appl, DocumentDescriptor desc)
          Starts processing the given application.
 void setProperty(String name, String value)
          Sets the property with the given name to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VoiceXmlInterpreterContext

public VoiceXmlInterpreterContext(JVoiceXmlSession currentSession,
                                  Configuration config)
Create a new object.

Parameters:
currentSession - the current session
config - the configuration to use.

VoiceXmlInterpreterContext

public VoiceXmlInterpreterContext(JVoiceXmlSession currentSession,
                                  Configuration config,
                                  ScopeObserver observer)
Create a new object.

Parameters:
currentSession - The current session
config - the configuration to use.
observer - the scope observer (not taken from the session).
Method Detail

getSession

public Session getSession()
Retrieves the current session.

Returns:
the current session.
Since:
0.7

getScopeObserver

public ScopeObserver getScopeObserver()
Retrieves the scope observer for this session.

Returns:
The scope observer.

getImplementationPlatform

public ImplementationPlatform getImplementationPlatform()
Retrieves a reference to the used implementation platform.

Returns:
The used implementation platform.

getGrammarProcessor

public GrammarProcessor getGrammarProcessor()
Retrieves a reference to the grammar processor.

Returns:
The grammar processor.
Since:
0.3

getConfiguration

public Configuration getConfiguration()
Retrieves the configuration.

Returns:
the configuration
Since:
0.7.4

getScriptingEngine

public ScriptingEngine getScriptingEngine()
Lazy instantiation of the scripting engine.

Returns:
the scripting engine.
Since:
0.3.1

getEventHandler

public EventHandler getEventHandler()
Retrieves the event handler to use in this context.

Returns:
the event handler.
Since:
0.7

enterScope

public void enterScope(Scope scope)
Enter a new scope for resolving variables. this is useful if we enter a new block, but at least every file should have it's own scope.

Parameters:
scope - the new scope.

exitScope

public void exitScope(Scope scope)
Return from a previously created scope. i.e. pop current scope from stack.

Parameters:
scope - The scope which was left.

close

public void close()
Closes all open resources.


getActiveGrammarSet

public ActiveGrammarSet getActiveGrammarSet()
Retrieves the active grammar set.

Returns:
the active grammar set.

setProperty

public void setProperty(String name,
                        String value)
Sets the property with the given name to the given value.

Parameters:
name - Name of the property.
value - Value of the property.

getProperty

public String getProperty(String name)
Retrieves the value of the given property.

Parameters:
name - Name of the property.
Returns:
Value of the property.

getProperty

public String getProperty(String name,
                          String defValue)
Retrieves the value of the given property.

Parameters:
name - name of the property.
defValue - the default value, if the property is not defined.
Returns:
value of the property or default value if no property is defined
Since:
0.7.4

getSpeechRecognizerProperties

public SpeechRecognizerProperties getSpeechRecognizerProperties(FormInterpretationAlgorithm fia)
                                                         throws ConfigurationException
Loads the speech recognizer properties. The values from the configuration are replaced by property settings if any.

Parameters:
fia - the current form interpretation algorithm, maybe null.
Returns:
the speech recognizer properties
Throws:
ConfigurationException - if the object could not be loaded.
Since:
0.7.5

getDtmfRecognizerProperties

public DtmfRecognizerProperties getDtmfRecognizerProperties(FormInterpretationAlgorithm fia)
                                                     throws ConfigurationException
Loads the DTMF recognizer properties. The values from the configuration are replaced by property settings if any.

Parameters:
fia - the current form interpretation algorithm, maybe null.
Returns:
the DTMF recognizer properties
Throws:
ConfigurationException - if the object could not be loaded.
Since:
0.7.5

getCallControlProperties

public CallControlProperties getCallControlProperties(FormInterpretationAlgorithm fia)
                                               throws ConfigurationException
Loads the speech recognizer properties. The values from the configuration are replaced by property settings if any.

Parameters:
fia - the current form interpretation algorithm, maybe null.
Returns:
the speech recognizer properties
Throws:
ConfigurationException - if the object could not be loaded.
Since:
0.7.5

getApplication

public Application getApplication()
Retrieves the application.

Returns:
the application.

process

public void process(Application appl)
             throws ErrorEvent
Starts processing the given application.

Parameters:
appl - The application to process.
Throws:
ErrorEvent - Error processing the document.

processSubdialog

public void processSubdialog(Application appl,
                             DocumentDescriptor desc)
                      throws JVoiceXMLEvent
Starts processing the given application.

Parameters:
appl - the application to process.
desc - the documnet descriptor for the subdialog
Throws:
JVoiceXMLEvent - Error processing the document.

isInitializingSubdialog

public boolean isInitializingSubdialog()
Checks if the interpreter is in the initialzing phase of a subdialog.

Returns:
true if the interpreter is in the initialzing phase of a subdialog.
Since:
0.7.4

loadDocument

public VoiceXmlDocument loadDocument(DocumentDescriptor descriptor)
                              throws BadFetchError
Loads the document of the descriptor with the associated attributes and adds it to the list of loaded documents.

If an application is active, the descriptor is also modified to contain the resolved URI.

Parameters:
descriptor - descriptor of the next document to process.
Returns:
VoiceXML document with the given URI
Throws:
BadFetchError - Error retrieving the document.
Since:
0.7

getDocumentServer

public DocumentServer getDocumentServer()
Retrieves a reference to the document server.

Returns:
Reference to the document server.

acquireVoiceXmlDocument

public VoiceXmlDocument acquireVoiceXmlDocument(DocumentDescriptor descriptor)
                                         throws BadFetchError
Acquires the VoiceXML document with the given URI.

If a relative URI is given, the scheme and authority of the last document are used to create a hierarchical URI for the next document.

Parameters:
descriptor - descriptor of the next document to process.
Returns:
VoiceXML document with the given URI
Throws:
BadFetchError - Error retrieving the document.

acquireExternalGrammar

public GrammarDocument acquireExternalGrammar(URI uri,
                                              FetchAttributes attributes)
                                       throws BadFetchError
Acquire the VoiceXML document with the given URI.

If a relative URI is given, the scheme and authority of the last document are used to create a hierarchical URI for the next document.

Parameters:
uri - URI of the next document to process.
attributes - attributes governing the fetch.
Returns:
Grammar document with the given URI.
Throws:
BadFetchError - Error retrieving the document.
Since:
0.3


Copyright © 2005-2010JVoiceXML group.