class JVoiceXmlDocumentServer implements DocumentServer {

    @Override
    public Object getObject(final String sessionId,
            final DocumentDescriptor descriptor, final String type)
            throws BadFetchError {
        final URI uri = descriptor.getUri();
        LOGGER.info("retrieving object with type '" + type + "' from '" + uri
                + "'");

        // Determine the relevant strategy
        final RequestMethod method = descriptor.getMethod();
        final Collection<KeyValuePair> parameters = descriptor.getParameters();
        final FetchAttributes attrs = descriptor.getAttributes();
        final FetchAttributes mergedAttrs = mergeFetchAttributes(attrs);
        final long timeout = mergedAttrs.getFetchTimeout();
        final SchemeStrategy strategy = getSchemeStrategy(uri);
        InputStream input = null;

        final Object object;
        try {
            input = strategy.getInputStream(sessionId, uri, method, timeout,
                    parameters);
            if (type == null) {
                final ReadBuffer buffer = new ReadBuffer();
                buffer.read(input);
                return buffer;
            } else if (type.equals(TEXT_PLAIN)) {
                final ReadBuffer buffer = new ReadBuffer();
                buffer.read(input);
                return buffer.toString();
            } else if (type.equals(TEXT_XML)) {
                object = readXml(input);
            } else {
                throw new BadFetchError("unknown type '" + type + "'");
            }
        } catch (IOException e) {
            throw new BadFetchError(e.getMessage(), e);
        } catch (UnsupportedElementError e) {
            throw new BadFetchError(e.getMessage(), e);
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    throw new BadFetchError(e);
                }
            }
        }

        return object;
    }

    public  JVoiceXmlDocumentServer();

}