class MappedDocumentStrategy implements SchemeStrategy {

    @Override
    public InputStream getInputStream(final String sessionId, final URI uri,
            final RequestMethod method, final long timeout,
            final Collection<KeyValuePair> parameters)
            throws BadFetchError {
        if (uri == null) {
            throw new BadFetchError("Unable to retrieve a document for null!");
        }
        final DocumentMap repository = DocumentMap.getInstance();

        // A jvxmlmap based URI may only have a scheme and a path.
        final String scheme = uri.getScheme();
        final String path = uri.getPath();
        final URI fragmentLessUri;
        try {
            fragmentLessUri = new URI(scheme, null, path, null);
        } catch (URISyntaxException e) {
            throw new BadFetchError(e.getMessage(), e);
        }
        final String document = repository.getDocument(fragmentLessUri);
        if (document == null) {
            return null;
        }

        String encoding = getEncoding(document);
        if (encoding == null) {
            encoding = System.getProperty("jvoicexml.xml.encoding", "UTF-8");
        }
        try {
            return new ByteArrayInputStream(document.getBytes(encoding));
        } catch (java.io.IOException ioe) {
            throw new BadFetchError(ioe);
        }
    }

    public  MappedDocumentStrategy();

}