class JVoiceXmlApplication implements Application {

    public void addDocument(final URI uri, final VoiceXmlDocument doc)
        throws BadFetchError {
        if (uri == null) {
            LOGGER.warn("no URI specified");
            return;
        }

        if (doc == null) {
            LOGGER.warn("cannot add a null document to application");
            return;
        }

        final Vxml vxml = doc.getVxml();
        if (vxml == null) {
            LOGGER.warn("Is this a VoiceXML document? No vxml tag found");
            return;
        }
        try {
            baseUri = vxml.getXmlBaseUri();
            if (baseUri == null) {
                baseUri = uri;
            }
            final URI currentApplication = vxml.getApplicationUri();
            if (currentApplication == null) {
                loadedDocuments.clear();
                root = null;
            }

            if (application == null) {
                application = currentApplication;
            } else if (!application.equals(currentApplication)) {
                application = baseUri;
                loadedDocuments.clear();
                root = null;
            }
        } catch (URISyntaxException e) {
            throw new BadFetchError(
                    "Error adding the document to the application", e);
        }

        current = doc;
        final URI resolved = resolve(uri);
        final URI fragmentLess = removeFragment(resolved);
        loadedDocuments.put(fragmentLess, current);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("loaded documents:");
            final Collection<URI> keys = loadedDocuments.keySet();
            for (URI loadedUri : keys) {
                LOGGER.debug("- " + loadedUri);
            }
        }
    }

    public  JVoiceXmlApplication();
    public  JVoiceXmlApplication(final ScopeObserver scopeObserver);

}