class Jsapi10SpokenInput implements SpokenInput, StreamableSpokenInput {

    @Override
    public GrammarImplementation<?> loadGrammar(final URI uri,
            final GrammarType type) throws NoresourceError, IOException,
            UnsupportedFormatError {
        if (recognizer == null) {
            throw new NoresourceError("No recognizer available!");
        }

        if (type != GrammarType.JSGF) {
            throw new UnsupportedFormatError(
                    "JSAPI 1.0 implementation supports only type "
                            + GrammarType.JSGF.getType());
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("loading grammar from URI '" + uri + "'");
        }
        final RuleGrammar grammar;
        try {
            final URL url = uri.toURL();
            InputStream input = url.openStream();
            final BufferedInputStream bufferedInput = new BufferedInputStream(
                    input);
            bufferedInput.mark(Integer.MAX_VALUE);
            final ByteArrayOutputStream out = new ByteArrayOutputStream();
            final byte[] buffer = new byte[256];
            int read = 0;
            do {
                read = bufferedInput.read(buffer);
                if (read > 0) {
                    out.write(buffer, 0, read);
                }
            } while (read >= 0);
            bufferedInput.reset();
            final InputStreamReader reader = new InputStreamReader(bufferedInput);
            grammar = recognizer.loadJSGF(reader);
        } catch (javax.speech.recognition.GrammarException ge) {
            throw new UnsupportedFormatError(ge.getMessage(), ge);
        }

        return new RuleGrammarImplementation(grammar, uri);
    }

    public  Jsapi10SpokenInput(final RecognizerModeDesc defaultDescriptor);

}