class JVoiceXmlEventHandler implements EventHandler {

    @Override
    public void collect(final VoiceXmlInterpreterContext context,
            final VoiceXmlInterpreter interpreter,
            final VoiceXmlDocument document) {
        final Vxml vxml = document.getVxml();
        final Collection<AbstractCatchElement> catches =
                new java.util.ArrayList<AbstractCatchElement>();
        final NodeList children = vxml.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            final Node child = children.item(i);
            if (child instanceof AbstractCatchElement) {
                final AbstractCatchElement catchElement =
                        (AbstractCatchElement) child;
                catches.add(catchElement);
            }
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("found " + catches.size()
                    + " catch elements in document");
        }

        // Transform them into event handlers.
        final FormInterpretationAlgorithm fia;
        if (interpreter == null) {
            fia = null;
        } else {
            fia = interpreter.getFormInterpretationAlgorithm();
        }
        for (AbstractCatchElement catchElement : catches) {
            final TokenList events = catchElement.getEventList();
            for (String eventType : events) {
                addCustomEvents(context, interpreter, fia, null, catchElement,
                        eventType);
            }
        }
    }

    public  JVoiceXmlEventHandler(final DataModel dataModel,
            final ScopeObserver observer);

}