private StringBuffer getSnippet()

in doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java [164:194]


    private StringBuffer getSnippet(URL url, String encoding, String id) throws IOException {
        StringBuffer result;

        String cachedSnippet = getCachedSnippet(url, id);

        if (cachedSnippet != null) {
            result = new StringBuffer(cachedSnippet);

            if (debug) {
                result.append("(Served from cache)");
            }
        } else {
            try {
                result = new SnippetReader(url, encoding).readSnippet(id);
                cacheSnippet(url, id, result.toString());
                if (debug) {
                    result.append("(Fetched from url, cache content ")
                            .append(cache)
                            .append(")");
                }
            } catch (IOException e) {
                if (ignoreDownloadError) {
                    LOGGER.debug("Exception while reading '{}'", url, e);
                    result = new StringBuffer("Error during retrieving content skip as ignoreDownloadError activated.");
                } else {
                    throw e;
                }
            }
        }
        return result;
    }