private String xrLine()

in maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java [593:636]


    private String xrLine(String line, String packageName, ClassType classType) {
        StringBuilder buff = new StringBuilder(line);

        String link;
        String find;
        String href;

        if (classType != null) {
            href = this.getHREF(packageName, classType);
            find = classType.getName();

            // build out what the link would be.
            link = "<a name=\"" + find + "\" href=\"" + href + "\">" + find + "</a>";
        } else {
            href = this.getHREF(packageName);
            find = packageName;

            // build out what the link would be.
            link = "<a href=\"" + href + "\">" + find + "</a>";
        }

        // use the SimpleWordTokenizer to find all entries
        // that match word. Then replace these with the link

        // now replace the word in the buffer with the link

        String replace = link;
        List<StringEntry> tokens = SimpleWordTokenizer.tokenize(buff.toString(), find);

        // JXR-141: If there are more than 1 tokens to be replaced,
        // then the start+end values are out of order during the
        // buff.replace.
        // Reversing the list solves it
        Collections.reverse(tokens);

        for (StringEntry token : tokens) {
            int start = token.getIndex();
            int end = token.getIndex() + find.length();

            buff.replace(start, end, replace);
        }

        return buff.toString();
    }