class ExternalGrammarDocument implements GrammarDocument {

    @Override
    public String getDocument() {
        if ((document == null) && (buffer != null)) {
            if (charset == null) {
                document = new String(buffer);
            } else {
                try {
                    document = new String(buffer, charset);
                } catch (UnsupportedEncodingException ex) {
                    LOGGER.warn("unable to use charset '" + charset
                            + "' to convert grammar '" + uri
                            + "'' Using default.", ex);
                    document = new String(buffer);
                }
            }
        }
        return document;
    }

    public  ExternalGrammarDocument(final URI source, final byte[] content,
            final String encoding, final boolean ascii);

}