org.jvoicexml.interpreter
Interface EventHandler

All Superinterfaces:
EventObserver
All Known Implementing Classes:
JVoiceXmlEventHandler

public interface EventHandler
extends EventObserver

Event handler to catch events generated from the ImplementationPlatform.

When an event is thrown, the scope in which the event is handled and its enclosing scopes are examined to find the best qualified catch element, according to the following algorithm:

  1. Form an ordered list of catches consisting of all catches in the current scope and all enclosing scopes (form item, form, document, application root document, interpreter context), ordered first by scope (starting with the current scope), and then within each scope by document order.
  2. Remove from this list all catches whose event name does not match the event being thrown or whose cond evaluates to false after conversion to boolean.
  3. Find the correct count: the highest count among the catch elements still on the list less than or equal to the current count value.
  4. Select the first element in the list with the correct count.

The name of a thrown event matches the catch element event name if it is an exact match, a prefix match or if the catch event attribute is not specified (note that the event attribute cannot be specified as an empty string - event="" is syntactically invalid). A prefix match occurs when the catch element event attribute is a token prefix of the name of the event being thrown, where the dot is the token separator, all trailing dots are removed, and a remaining empty string matches everything.

Version:
$Revision: 154 $
Author:
Dirk Schnelle
See Also:

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


Method Summary
 void addStrategy(AbstractEventStrategy strategy)
          Add a strategy for the given event type.
 void collect(VoiceXmlInterpreterContext context, VoiceXmlInterpreter interpreter, FormInterpretationAlgorithm fia, FieldFormItem field)
          Add all event handlers defined in the given field.
 JVoiceXMLEvent getEvent()
          Retrieve the event.
 void processEvent(InputItem input)
          Process the last received event.
 JVoiceXMLEvent waitEvent()
          Wait until an event was generated in the implementation platform.
 
Methods inherited from interface org.jvoicexml.event.EventObserver
notifyEvent
 

Method Detail

collect

void collect(VoiceXmlInterpreterContext context,
             VoiceXmlInterpreter interpreter,
             FormInterpretationAlgorithm fia,
             FieldFormItem field)
Add all event handlers defined in the given field.

Parameters:
context - The current VoiceXmlInterpreterContext
interpreter - The current VoiceXmlInterpreter
fia - The current FIA.
field - The field.

waitEvent

JVoiceXMLEvent waitEvent()
Wait until an event was generated in the implementation platform.

Returns:
The caught event.

processEvent

void processEvent(InputItem input)
                  throws JVoiceXMLEvent
Process the last received event.

Parameters:
input - The current input item.
Throws:
JVoiceXMLEvent - Error or event processing the event.

addStrategy

void addStrategy(AbstractEventStrategy strategy)
Add a strategy for the given event type.

Parameters:
strategy - The strategy to add.

getEvent

JVoiceXMLEvent getEvent()
Retrieve the event.

Returns:
The caught event.


Copyright © 2005-2007 JVoiceXML group.